refactored login to use mongo db model