Fixing redirect loop and user creation

If you try the rails example right now you will be stuck in a redirect loop. The application doesn't take care of user creation. This should fix this and create users in the DB if they are not found.