Added login function to User model.