public bool IsLoginModelValid(LoginUserBindingModels model) { if (!this.Context.Users.Any(u => (u.Email == model.UsernameOrEmail || u.Username == model.UsernameOrEmail) && u.Password == model.Password)) { return(false); } return(true); }
public IActionResult Login(HttpResponse response, HttpSession session, LoginUserBindingModels model) { if (!this.service.IsLoginModelValid(model)) { this.Redirect(response, "/forum/login"); return(null); } User user = this.service.GetUserFromLoginBind(model); this.service.LoginUser(user, session.Id); this.Redirect(response, "/home/topics"); return(null); }
public User GetUserFromLoginBind(LoginUserBindingModels model) { return(this.Context.Users.First(u => (u.Email == model.UsernameOrEmail || u.Username == model.UsernameOrEmail) && u.Password == model.Password)); }