Functional login and registration to mongodb