Example #1
0
        public void Test_hashing_functions_same()
        {
            var pwd1 = "psfwer@12swe";
            var hash = Hashing.GenerateHash(pwd1);

            Assert.IsTrue(Hashing.CheckPassword(pwd1, hash));
        }
Example #2
0
        public void Test_hashing_functions_different()
        {
            var pwd1 = "asdwe929weQwr_";
            var pwd2 = "wermlvd9eo33_";
            var hash = Hashing.GenerateHash(pwd1);

            Assert.IsFalse(Hashing.CheckPassword(pwd2, hash));
        }
Example #3
0
        public ActionResult LogIn(LogInModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = PortalDbContext.Get())
                {
                    var user =
                        db.Users.FirstOrDefault(
                            u => u.Email.Equals(model.Email, StringComparison.InvariantCultureIgnoreCase));
                    if (user != null)
                    {
                        if (Hashing.CheckPassword(model.Password, user.PasswordHash))
                        {
                            FormsAuthentication.SetAuthCookie(user.Id.ToString(), model.RememberMe);
                            return(RedirectToAction("Edit"));
                        }
                    }
                }
            }

            return(View(model));
        }
Example #4
0
            public override PasswordVerificationResult VerifyHashedPassword(string hashedPassword, string providedPassword)
            {
                var isSame = Hashing.CheckPassword(providedPassword, hashedPassword);

                return(isSame ? PasswordVerificationResult.Success : PasswordVerificationResult.Failed);
            }