Ejemplo n.º 1
0
        public void HashingPassword()
        {
            string passwd = "ABCDE";
            string hashed = manager.HashPassword(passwd);

            Assert.AreEqual(true, manager.VerifyPassword(hashed, passwd));
            Assert.AreEqual(false, manager.VerifyPassword(hashed, "ABCDEF"));
        }
        public ActionResult PrivatePollAuth(PrivatePollPasswordModelView modelView)
        {
            //check if poll exist
            var poll = db.Polls.Find(modelView.Id);

            if (poll == null)
            {
                return(new HttpNotFoundResult());
            }
            var privatePollManager = new PrivatePollManager();

            if (privatePollManager.VerifyPassword(poll.Password, modelView.Password))
            {
                Response.Cookies.Add(privatePollManager.GetSessionCookie(db, poll));//give user session that last 10 minutes
                return(RedirectToAction("PollVote", "Home", new { @id = modelView.Id }));
            }
            else
            {
                ModelState.AddModelError("passwdNotValid", "Password is not correct.");
                return(View(modelView));
            }
        }