public HttpResponse Login(LoginForemViewModel model)
        {
            (string userId, string error) = UserService.Login(model);

            if (string.IsNullOrEmpty(userId) || string.IsNullOrWhiteSpace(userId))
            {
                return(Error(error));
            }

            this.SignIn(userId);

            return(Redirect("/"));
        }
Ejemplo n.º 2
0
        public (string userId, string error) Login(LoginForemViewModel model)
        {
            var    hashedPassword = this.passwordHasher.GeneratePassword(model.Password);
            string modelErrors    = string.Empty;

            var userId = this.Data
                         .Users
                         .Where(u => u.Username == model.Username && u.Password == hashedPassword)
                         .Select(u => u.Id)
                         .FirstOrDefault();

            if (userId == null)
            {
                modelErrors = "Wrong Login Information, UserName or Password are incorect";
            }

            return(userId, modelErrors);
        }