user login refactoring