Putting a form into a menu
Drupal already has a login block, which displays the login form, which by default only is displayed for anynomous users. So all you really need to do is add a block with the User menu (all menus has a block with the items) next to the login block and have it show for only authenticated users.

This is one of the things where configuration will get you all the way.