Пример #1
0
        public void ValidatePassword_WrongPassword_ShouldReturnFalse()
        {
            var  user   = PasswordHashService.HashPassword("Pa55word");
            bool result = PasswordHashService.ValidatePassword("Password", user);

            Assert.IsFalse(result);
        }
Пример #2
0
        public ActionResult Login(LoginUserViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var query = from u in db.Users
                        where u.Name == model.Username
                        select u;

            var user = query.FirstOrDefault();

            if (user == null || !PasswordHashService.ValidatePassword(model.Password, user.Password))
            {
                FlashMessageHelper.SetMessage(this, FlashMessageType.Warning, "Autoryzacja użytkownika nie przebiegła pomyślnie.");
                return(View(model));
            }

            UserSessionContext us = new UserSessionContext(HttpContext);

            us.SetUserId(user.Id);

            return(RedirectToAction("Index", "Character"));
        }
Пример #3
0
        public void ValidatePassword_CorrectPassword_ShouldReturnTrue()
        {
            var  user   = PasswordHashService.HashPassword("Pa55word");
            bool result = PasswordHashService.ValidatePassword("Pa55word", user);

            Assert.IsTrue(result);
        }