public ActionResult ForgotPassword(Forgotpassword forgotpassword) { string output = "User account not found"; try { if (ModelState.IsValid) { var message = string.Empty; UserRepository repository = new UserRepository(); var result = repository.ForgotUserLoginDetail(forgotpassword.MobileNo, forgotpassword.EmailAddress, out message); if (result.Response) { output = "Send password details on your email address"; ViewBag.Message = "Send password details on your email address"; } else { ViewBag.Message = string.IsNullOrEmpty(message) ? "Operation fail due to some reason." : message; } } } catch (Exception exp) { } return(View()); }
public ActionResult ForgotPassword(Forgotpassword forgotpassword, string ReturnUrl = "") { string message = ""; bool Status = false; using (var context = new AdminDataContext()) { User entity = context.Users.FirstOrDefault(x => x.Email == forgotpassword.Email); if (entity != null) { if (string.Compare(forgotpassword.Ques1, entity.Ques1) == 0 && string.Compare(forgotpassword.Ques2, entity.Ques2) == 0 && string.Compare(forgotpassword.Ques3, entity.Ques3) == 0) { entity.Password = forgotpassword.NewPassword; entity.ConfirmPassword = entity.Password; context.Entry(entity).State = EntityState.Modified; context.SaveChanges(); Status = true; message = $"Password successfully changed for {entity.Email}"; } else { message = "Wrong Answers to the Questions"; } } else { message = "User with this email dosen't exist"; } } ViewBag.Message = message; ViewBag.Status = Status; return(View(forgotpassword)); }
public ActionResult ForgotPassWord(Forgotpassword xyz) { if (objcon.Users.Any(model => model.Email == xyz.Email)) { ForgotPassSentEmail(xyz); return(View()); } else { ModelState.AddModelError("Error", "Email Id does not exists"); return(View()); } }
public int Updatepassword(Forgotpassword forgotpassword) { var result = 0; if (con.State == ConnectionState.Closed) { con.Open(); } DynamicParameters parameters = new DynamicParameters(); parameters.Add("@UserId", forgotpassword.UserId); parameters.Add("@Password", forgotpassword.Password); result = SqlMapper.Execute(con, "EAPUpdatepassword", parameters, commandType: CommandType.StoredProcedure); return(result); }
public ActionResult Updatepassword(Forgotpassword forgotpassword) { string UserId = (forgotpassword.UserId.Replace("œ", "+").Replace("Ž", "=").Replace("ô", "/")); forgotpassword.UserId = EncryptionDecryptionHelper.DecryptString(UserId); forgotpassword.Password = EncryptionDecryptionHelper.EncryptString(forgotpassword.Password); _logger.LogInformation("Post: api/MobileUser/Updatepassword Invoke"); ResponseModel responseModel = new ResponseModel(); var result = _userService.Updatepassword(forgotpassword); if (result <= 0) { responseModel.IsSuccess = false; responseModel.Message = "Record Not Updated"; } else { responseModel.Result = "Update"; } return(Ok(responseModel)); }
private void ForgotPassSentEmail(Forgotpassword xyz) { var check = objcon.Users.Where(x => x.Email == xyz.Email).FirstOrDefault(); using (MailMessage mm = new MailMessage("*****@*****.**", xyz.Email)) { mm.Subject = "NoteMarketPlace - Temporary Password"; var body = "<p>Hello,</p> <p>Your newly generated password is:<p> <p>{0}</p> <p>Thanks,</p><p>Team Notes MarketPlace</p>"; string NewPassword = GeneratePassword().ToString(); body = string.Format(body, NewPassword); mm.Body = body; mm.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential Network = new NetworkCredential("*****@*****.**", "dkp@123456"); smtp.UseDefaultCredentials = true; smtp.Credentials = Network; smtp.Port = 587; smtp.Send(mm); if (NewPassword != null) { var Replace = objcon.Users.Where(x => x.Email == xyz.Email).FirstOrDefault(); if (Replace != null) { Replace.Password = NewPassword; Replace.Password = Trails.Models.encryptPassword.textToEncrypt(Replace.Password); objcon.SaveChanges(); } } } }
public IHttpActionResult forgotpassword(Forgotpassword forgotpassword) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { Random random_number = new Random(); int OTP = random_number.Next(1000, 9999); var user = db.User_Master.Where(x => x.email_id == forgotpassword.email).FirstOrDefault(); if (user == null) { return(BadRequest("user doesnot exist")); } var user_in_otp = db.user_otp.Where(x => x.userid == user.userid).FirstOrDefault(); if (user_in_otp != null) { db.user_otp.Remove(user_in_otp); try { db.SaveChanges(); } catch (Exception ex) { return(BadRequest(ex.ToString())); } } user_otp userobj = new user_otp(); userobj.userid = user.userid; userobj.otp = OTP; db.user_otp.Add(userobj); try { db.SaveChanges(); } catch (Exception ex) { return(BadRequest(ex.ToString())); } MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(forgotpassword.email); mail.Subject = "Airlines OTP"; mail.Body = OTP.ToString(); SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "radioactive1!"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); return(Ok("Mail Sent")); } catch (Exception ex) { return(BadRequest(ex.ToString())); } }
public int Updatepassword(Forgotpassword forgotpassword) { return(_userRepository.Updatepassword(forgotpassword)); }
public ActionResult ForgotPassWord() { Forgotpassword obj = new Forgotpassword(); return(View()); }