Refactored login and password reset