public ActionResult ForgotLoginID(string EmailID) {//verify Email ID string message = ""; // bool status = false; using (Models.LoginDataModel db = new Models.LoginDataModel()) { var account = db.tblTropicalUser.Where(a => a.Email == EmailID).FirstOrDefault(); if (account != null) { //send Email for telling the LoginID //string resetCode = Guid.NewGuid().ToString(); SendForgotIDEmail(account.Email, "ForgotID", account.LoginID); //account.ResetPasswordCode = resetCode; db.Configuration.ValidateOnSaveEnabled = false;//remove reset pw does not match issue db.SaveChanges(); message = "Your LoginID has been sent to your email. Your Login ID is: " + account.LoginID; } else { message = "Account not found"; } } //Generate reset password link ViewBag.Message = message; return(View()); }
public ActionResult ResetPassWord(ResetPasswordModel model) { var message = ""; if (ModelState.IsValid) { using (Models.LoginDataModel db = new Models.LoginDataModel()) { var user = db.tblTropicalUser.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault(); if (user != null) { user.Password = Crypto.Hash(model.NewPassword); user.ResetPasswordCode = ""; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); message = "New password updated successfully"; } } } else { message = "Something invalid"; } ViewBag.Message = message; return(View(model)); }
public ActionResult Authorize(TropicalServerApp.Models.tblTropicalUser userModel) { HttpCookie cookie = new HttpCookie("tblTropicalUser"); using (Models.LoginDataModel db = new Models.LoginDataModel()) { var userDetails = db.tblTropicalUser.Where(x => x.LoginID == userModel.LoginID && x.Password == userModel.Password).FirstOrDefault(); if (userDetails == null) { //login failed userModel.LoginErrorMessage = "Wrong Login ID or Password."; return(View("Login", userModel)); } else { //login success System.Web.Security.FormsAuthentication.SetAuthCookie(userModel.LoginID, userModel.RememberMe); Session["loginID"] = userDetails.LoginID; Session["userName"] = userDetails.FirstName; if (userModel.RememberMe) { //cookie.Values.Add("LoginID", userDetails.LoginID); cookie["loginID"] = userModel.LoginID; cookie.Expires = DateTime.Now.AddDays(15); HttpContext.Response.Cookies.Add(cookie); } return(RedirectToAction("Index", "Order")); //action name, controller name } } }
public ActionResult ResetPassword(string id) { //verify reset pw link //find account associated with this link //redirect to reset pw page using (Models.LoginDataModel db = new Models.LoginDataModel()) { var user = db.tblTropicalUser.Where(a => a.ResetPasswordCode == id).FirstOrDefault(); if (user != null) { ResetPasswordModel model = new ResetPasswordModel(); model.ResetCode = id; return(View(model)); } else { return(HttpNotFound()); } } }