Created login function for AppUser model.