Refactor login logic to the login widget.

**DO NOT MERGE**

A little work needs to be done yet.
Can we get the sequence/steps documented in the top module documentation? I still need to trace the cascading calls every time.