public ActionResult Login(LoginModel model) { try { if (ModelState.IsValid) { if (HttpContext.Session != null) HttpContext.Session.Abandon(); AdminBAL _AdminBAL = new AdminBAL(); var user = _AdminBAL.ValidUser(); if (user != null) { if (ModelState.IsValid && (model.Password == user.Password)) { FormsAuthentication.SetAuthCookie("Admin", false); FormsAuthenticationTicket formsAuthenticationTicket = new FormsAuthenticationTicket("Admin", false, 240); HttpCookie httpCookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(formsAuthenticationTicket)); Response.Cookies.Add(httpCookie); if (Request.QueryString["ReturnUrl"] == null) return RedirectToAction("Index", "Dashboard"); else return Redirect(Request.QueryString["ReturnUrl"]); } else { TempData["errormsg"] = "The email or password provided is incorrect"; } } else { TempData["errormsg"] = "Admin Does Not Exist"; } } } catch (Exception ex) { TempData["errormsg"] = ex.Message; } return View(model); }
public ActionResult ChangePassword(LoginModel model) { try { //var Member = _MemberBAL.GetByName(Convert.ToInt32(Session["MembershipNo"])); var Member = _MemberBAL.GetByName(User.Identity.Name); Member.Password = model.Password; new MemberBAL().Update(Member); TempData["successmsg"] = "Password Changed Succesfully"; } catch (Exception ex) { TempData["errormsg"] = ex.Message; } return Redirect("ChangePassword"); }
public ActionResult ChangePassword(LoginModel model) { try { if (ModelState.IsValid) { var Admin = _AdminBAL.GetByName(User.Identity.Name); Admin.Password = model.Password; new AdminBAL().Update(Admin); TempData["successmsg"] = "Password Changed Succesfully"; } } catch (Exception ex) { TempData["errormsg"] = ex.Message; } return Redirect("ChangePassword"); }
public ActionResult Login(LoginModel model) { try { if (ModelState.IsValid) { if (HttpContext.Session != null) HttpContext.Session.Abandon(); var Member = _MemberBAL.GetMember(model.MemberShipNo); if (Member != null) { if (ModelState.IsValid && (model.Password == Member.Password)) { //Session["MembershipNo"] = Member.MemberShipNo; FormsAuthentication.SetAuthCookie(Member.Name.ToString(), false); FormsAuthenticationTicket formsAuthenticationTicket = new FormsAuthenticationTicket(Member.Name.ToString(), false, 240); HttpCookie httpCookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(formsAuthenticationTicket)); Response.Cookies.Add(httpCookie); if (Request.QueryString["ReturnUrl"] == null) return RedirectToAction("Index", "MemberDashboard"); else return Redirect(Request.QueryString["ReturnUrl"]); } else { TempData["errormsg"] = "The email or password provided is incorrect"; } } else { TempData["errormsg"] = "Member Does Not Exist"; } } } catch (Exception ex) { TempData["errormsg"] = ex.Message; } return View(model); }