Esempio n. 1
0
 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);
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public User GetUserFromLoginBind(LoginUserBindingModels model)
 {
     return(this.Context.Users.First(u => (u.Email == model.UsernameOrEmail || u.Username == model.UsernameOrEmail) &&
                                     u.Password == model.Password));
 }