Implement user authentication

So many conflicts. The main contribution for this pull request was getting user auth working.