Example #1
0
        public IActionResult Login(UserLoggingInModel model)
        {
            var user = this.Context
                       .Users
                       .Include(r => r.Role)
                       .Where(u => u.Username == model.Username)
                       .Select(u => u)
                       .FirstOrDefault();

            if (user == null)
            {
                this.ViewData.Data["error"] = "Invalid username and / or password";
                return(this.View());
            }

            string passwordHash = PasswordUtilities.GetPasswordHash(model.Password);

            if (user.PasswordHash != passwordHash)
            {
                this.ViewData.Data["error"] = "Invalid username and / or password";
                return(this.View());
            }

            this.SignIn(user.Username, user.Id, new List <string>()
            {
                user.Role.RoleName
            });
            return(this.RedirectToHome());
        }
Example #2
0
        public IActionResult Login(UserLoggingInModel model)
        {
            var user = this.users.UserExists(model.Username, model.Password);

            if (user == null)
            {
                ShowError("Invalid credentials!");
                return(this.View());
            }

            this.SignIn(user.Username, user.Id);
            return(this.RedirectToHome());
        }
Example #3
0
        public IActionResult Login(UserLoggingInModel model)
        {
            var user = this.Context.Users
                       .FirstOrDefault(u => u.Username == model.Username);

            if (user == null)
            {
                this.Model.Data["error"] = "Invalid username and / or password";
                return(this.View());
            }

            string passwordHash = PasswordUtilities.GetPasswordHash(model.Password);

            if (user.PasswordHash != passwordHash)
            {
                this.Model.Data["error"] = "Invalid username and / or password";
                return(this.View());
            }

            this.SignIn(user.Username, user.Id);
            return(this.RedirectToHome());
        }