Esempio n. 1
0
        public ActionResult ResetPasswordConfirmation(string token, string id)
        {
            //if (WebSecurity.ResetPassword(model.Token, model.NewPassword))
            //{
            //    return RedirectToAction("PasswordResetSuccess");
            //}
            ModelServices modelServices = new ModelServices();

            try
            {
                if (modelServices.IsResetTokenValid(token, id))
                {
                    ResetPasswordConfirmModel data = new ResetPasswordConfirmModel()
                    {
                        Token = token
                    };
                    return(View(data));
                }
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return(View("GeneralError"));
            }
            return(RedirectToAction("PasswordResetFailure"));
        }
Esempio n. 2
0
 public ActionResult ResetPasswordConfirmation(ResetPasswordConfirmModel model)
 {
     if (WebSecurity.ResetPassword(model.Token, model.NewPassword))
     {
         return(RedirectToAction("PasswordResetSuccess"));
     }
     return(RedirectToAction("PasswordResetFailure"));
 }
Esempio n. 3
0
        public ActionResult ResetPasswordConfirmation(string Id)
        {
            var model = new ResetPasswordConfirmModel {
                Token = Id
            };

            return(View(model));
        }
        public ActionResult ResetPasswordPatient(string unp, string rtp)
        {
            ResetPasswordConfirmModel model = new ResetPasswordConfirmModel();

            model.EmailId      = unp;
            model.Token        = rtp;
            Session["EmailId"] = model.EmailId;
            Session["Token"]   = model.Token;
            return(View(model));
        }
Esempio n. 5
0
        public ActionResult ResetPasswordConfirmation(ResetPasswordConfirmModel model)
        {
            if (WebSecurity.ResetPassword(model.Token, model.NewPassword))
            {
                //Return to success page
                return(RedirectToAction(""));
            }

            //Return Passowrd return failure
            return(RedirectToAction(""));
        }
Esempio n. 6
0
        public ActionResult ResetPasswordConfirmation(ResetPasswordConfirmModel model)
        {
            if (ModelState.IsValid)
            {
                if (WebSecurity.ResetPassword(model.Token, model.NewPassword))
                {
                    logger.Info("Password reset with token: " + model.Token + ". New password: "******"PasswordResetSuccess"));
                }
                return(RedirectToAction("PasswordResetFailure"));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Esempio n. 7
0
        public ActionResult ResetPasswordConfirmation(ResetPasswordConfirmModel model)
        {
            ModelServices modelServices = new ModelServices();

            try
            {
                string aspId = modelServices.GetAspUserIdForToken(model.Token);

                UserManager.RemovePassword(aspId);
                UserManager.AddPassword(aspId, model.NewPassword);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return(View("GeneralError"));
            }
            return(RedirectToAction("PasswordResetComplete"));
        }
Esempio n. 8
0
        public async Task <IActionResult> ResetPassword(ResetPasswordConfirmModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.FindByIdAsync(model.UserId);

                if (user != null)
                {
                    var result = await _userManager.ResetPasswordAsync(user, model.Token, model.NewPassword);

                    if (result.Succeeded)
                    {
                        return(Ok());
                    }

                    return(BadRequest(result.Errors));
                }
            }

            return(BadRequest());
        }
Esempio n. 9
0
 public ActionResult ResetPasswordConfirmation(string Id)
 {
     var model = new ResetPasswordConfirmModel() { Token = Id };
     return this.View(model);
 }
Esempio n. 10
0
        public async Task<ActionResult> ResetPasswordConfirmation(ResetPasswordConfirmModel model)
        {
            var user = this.db.Users.FirstOrDefault(entry => entry.EmailResetToken == model.Token);
            if (user == null || !this.ResetPassword(user, model.NewPassword))
            {
                return this.RedirectToAction("Failure", new { id = "Reset" });
            }

            await this.SignInAsync(user, isPersistent: false);
            return this.RedirectToAction("Success", new { id = "Reset" });
        }
Esempio n. 11
0
        public ActionResult ResetPasswordPatient(ResetPasswordConfirmModel model)
        {
            model.EmailId = Session["EmailId"].ToString();
            model.Token   = Session["Token"].ToString();
            if (ModelState.IsValid)
            {
                //TODO: Check the un and rt matching and then perform following
                //get userid of received username
                var EmailId = (from i in db.patientlogins
                               where i.EmailID == model.EmailId
                               select i.EmailID).FirstOrDefault();
                //check userid and token matches

                bool any = (from j in db.patientlogins
                            where (j.EmailID == model.EmailId) &&
                            (j.PasswordVerificationToken == model.Token)
                            //&& (j.PasswordVerificationTokenExpirationDate < DateTime.Now)
                            select j).Any();

                if (any == true)
                {
                    var UpdateUser = db.patientlogins.Where(a => a.EmailID == EmailId).FirstOrDefault();
                    //Setting password expiry date
                    if (UpdateUser.PasswordVerificationTokenExpirationDate > System.DateTime.Now)
                    {
                        if (UpdateUser != null)
                        {
                            var crypto     = new SimpleCrypto.PBKDF2();
                            var encrypPass = crypto.Compute(model.NewPassword);
                            UpdateUser.Password        = encrypPass;
                            UpdateUser.ConfirmPassword = encrypPass;
                            UpdateUser.PasswordSalt    = crypto.Salt;
                        }
                        db.SaveChanges();
                        //reset password
                        //send email
                        string subject = "New Patient Password";
                        string body    = "<b>Your password has been changed as per our record, Please login with your new password</b><br/>";//edit it
                        try
                        {
                            SendEMail sendemail = new SendEMail();
                            sendemail.Send_EMail(EmailId, subject, body);
                            ViewBag.StatusMessage = "Patient Password has been reset now and An email has been sent to the email address you registered with for confirmation.";
                        }
                        catch (Exception ex)
                        {
                            ViewBag.StatusMessage = "Error occured while sending email to Patient." + ex.Message;
                        }
                        ViewBag.Status = 1;
                        return(View());
                    }
                    else
                    {
                        ModelState.AddModelError("", "Patient Reset Password Token is expired, Use Forgot password link from login screen to regenerate your tocken");
                    }
                }
                else
                {
                    if (model.Token == null)
                    {
                        ModelState.AddModelError("", "Patient- No Valid Token found, Use Forgot password link from login screen to regenerate your token");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Patient- Input Token number is not correct or expired");
                    }
                }
            }
            return(View(model));
        }