Made the basic login form work.

You're now actually logged in.

Also split moved the global parts of it to the authentication library.