small refactors around User.try_to_login