//public async Task<ActionResult> ChangePassword(MemberChangePasswordModel value) public async Task <JsonResult> ChangePassword(MemberChangePasswordModel value) { initpage();//// var db = new DBContext(); using (System.Data.Entity.DbContextTransaction ContextTransaction = db.Database.BeginTransaction()) { try { long mem_id = MemberCurrentUser.MEM_ID; var changepass = db.TBL_MASTER_MEMBER.Where(x => x.MEM_ID == mem_id).FirstOrDefault(); if (changepass != null) { if (changepass.User_pwd == value.OldUser_pwd) { var userpass = value.User_pwd; //userpass = userpass.GetPasswordHash(); changepass.User_pwd = userpass; db.Entry(changepass).State = System.Data.Entity.EntityState.Modified; await db.SaveChangesAsync(); //throw new Exception(); var token = TokenGenerator.GenerateToken(); var PasswordResetObj = new TBL_PASSWORD_RESET { ID = token, EmailID = changepass.EMAIL_ID, Time = DateTime.Now }; db.TBL_PASSWORD_RESET.Add(PasswordResetObj); db.SaveChanges(); ContextTransaction.Commit(); FormsAuthentication.SignOut(); FormsAuthentication.SignOut(); Session["WhiteLevelUserId"] = null; Session["WhiteLevelUserName"] = null; Session.Clear(); Session.Remove("WhiteLevelUserId"); Session.Remove("WhiteLevelUserName"); //return RedirectToAction("Message"); return(Json("Password changed Successfully", JsonRequestBehavior.AllowGet)); } else { return(Json("Please Enter Valid Old Password ", JsonRequestBehavior.AllowGet)); } } return(Json("OK", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ContextTransaction.Rollback(); Logger.Error("Controller:- MemberChangePassword(Admin), method:- ChangePassword (POST) Line No:- 271", ex); throw ex; return(Json("Try Again After Sometime", JsonRequestBehavior.AllowGet)); //return View("Error", new HandleErrorInfo(ex, "APILabel", "CreateMember")); } } }
public async Task <ActionResult> ChangePassword(MemberChangePasswordModel value) { initpage();//// var db = new DBContext(); using (System.Data.Entity.DbContextTransaction ContextTransaction = db.Database.BeginTransaction()) { try { long mem_id = MemberCurrentUser.MEM_ID; var changepass = db.TBL_MASTER_MEMBER.Where(x => x.MEM_ID == mem_id).FirstOrDefault(); if (changepass != null) { changepass.User_pwd = value.User_pwd; db.Entry(changepass).State = System.Data.Entity.EntityState.Modified; await db.SaveChangesAsync(); } //throw new Exception(); ContextTransaction.Commit(); FormsAuthentication.SignOut(); Session["SuperDistributorId"] = null; Session["SuperDistributorUserName"] = null; Session.Clear(); Session.Remove("SuperDistributorId"); Session.Remove("SuperDistributorUserName"); //return RedirectToAction("Message"); return(RedirectToAction("Message", "SuperLogin", new { area = "Super" })); } catch (Exception ex) { ContextTransaction.Rollback(); Logger.Error("Controller:- SuperChangePassword(Super), method:- ChangePassword (POST) Line No:- 127", ex); return(RedirectToAction("Exception", "ErrorHandler", new { area = "" })); throw ex; //return View("Error", new HandleErrorInfo(ex, "APILabel", "CreateMember")); } } }
public ActionResult ChangePassword(MemberChangePasswordModel m) { try { if (!Members.CheckMemberPassword(MemberSession.GetMemberId(), m.OldPassword)) { return(RedirectToAction("ChangePassword", new { message = "Pogresna stara lozinka." })); } else if (m.NewPassword != m.RepeatPassword) { return(RedirectToAction("ChangePassword", new { message = "Polja za novu lozinku nisu jednaka." })); } else { Members.ChangeMemberPassword(MemberSession.GetMemberId(), m.NewPassword); } return(RedirectToAction("ChangePassword", new { message = "Nesto ne valja." })); } catch (Exception) { return(RedirectToAction("Index", "Access")); } }