Login api

This needs some serious reworking, but it should be functional now.

Would very much enjoy changes/input on this.