public ActionResult doForgotPasswordUpdate(string Answer, string NewPassword, string ConfirmNewPassword, string IDNumber)
 {
     using (VotingSystemProjectEntities3 db = new VotingSystemProjectEntities3())
     {
         var ans    = registerVoter.HashedData(Answer);
         var idnum  = registerVoter.HashedData(IDNumber);
         var search = db.Voters.Where(x => x.VoterIDNumber == idnum && x.SecurityQuestionAnswer == ans).FirstOrDefault();
         if (search != null)
         {
             if (NewPassword == ConfirmNewPassword)
             {
                 string hassednew  = registerVoter.HashedData(NewPassword);
                 string hassedcnew = registerVoter.HashedData(ConfirmNewPassword);
                 search.VoterPassword = hassednew;
                 db.SaveChanges();
                 TempData["success"] = "Your Password has been updated";
                 return(RedirectToAction("Voterlogin"));
             }
         }
         else
         {
             TempData["message"] = "Your your Security Question Answer was incorrect! Please try again!";
             return(RedirectToAction("ForgotPassword", new { IDnum = IDNumber }));
         }
     }
     TempData["message"] = "Your Password was not updated";
     return(RedirectToAction("VoterLogin"));
 }
        public ActionResult doUpdatePassword(string Answer, string NewPassword, string ConfirmNewPassword, string VoterGUID, string id)
        {
            VoterVM voterVM = TempData["voterVM"] as VoterVM;

            registerVoter.voterView = voterVM;

            using (VotingSystemProjectEntities3 db = new VotingSystemProjectEntities3())
            {
                var ans    = registerVoter.HashedData(Answer);
                var vid    = Convert.ToInt32(id);
                var search = db.Voters.Where(x => x.VoterID == vid && x.SecurityQuestionAnswer == ans).FirstOrDefault();
                if (search != null)
                {
                    if (NewPassword == ConfirmNewPassword)
                    {
                        string hassednew  = registerVoter.HashedData(NewPassword);
                        string hassedcnew = registerVoter.HashedData(ConfirmNewPassword);
                        search.VoterPassword = hassednew;
                        db.SaveChanges();
                        TempData["success"] = "Your Password has been updated";
                        return(RedirectToAction("VoterHomePage", new { VoterGUID = registerVoter.voterView.voter.GUID }));
                    }
                }
                else
                {
                    TempData["message"] = "Your Security Question Answer was wrong! Please try again!";
                    return(RedirectToAction("ChangePasswordVoter", new { VoterGUID = registerVoter.voterView.voter.GUID, id = registerVoter.voterView.voter.VoterID }));
                }
            }
            TempData["message"] = "An Error Occured!";
            return(RedirectToAction("VoterHomePage", new { VoterGUID = registerVoter.voterView.voter.GUID }));
        }
Exemplo n.º 3
0
 public bool IsLogedIn(VotingSystemProjectEntities3 db, string userGUID)
 {
     db.Configuration.ProxyCreationEnabled = false;
     voter = db.Voters.Where(x => x.GUID == userGUID && x.GUIDTimeStamp > DateTime.Now).FirstOrDefault();
     if (voter != null)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
        public bool IsLogedIn(VotingSystemProjectEntities3 db)
        {
            db.Configuration.ProxyCreationEnabled = false;
            var guid = db.Voters.Where(x => x.GUID == voter.GUID && x.GUIDTimeStamp > DateTime.Now).Count();

            if (guid > 0)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 5
0
        public void RefreshGUID(VotingSystemProjectEntities3 db)
        {
            db.Configuration.ProxyCreationEnabled = false;

            voter.GUID          = Guid.NewGuid().ToString();
            voter.GUIDTimeStamp = DateTime.Now.AddMinutes(30);
            var g = db.Voters.Where(x => x.GUID == voter.GUID).Count();

            if (g > 0)
            {
                RefreshGUID(db);
            }
            else
            {
                var u = db.Voters.Where(z => z.VoterID == voter.VoterID).FirstOrDefault();
                db.Entry(u).CurrentValues.SetValues(voter);
                db.SaveChanges();
            }
        }