Implemented auto-creating user if none exists.
Let the DB session last the whole function.