Refactor login logic to the login widget.

**DO NOT MERGE**

A little work needs to be done yet.
sounds good, but I would add a line explaining what to expect from each step (what logic it is supposed to do)