Refactoring for logins and user management (as part of admin)