Move login logic to user model