public int ResetEmployeePassword(Employee emp) { int result = 0; try { UserLogonData userLogon = new UserLogonData(); Encrypt encrypt = new Encrypt(); string password = encrypt.CreateRandomPassword(6); string hashPwd = encrypt.GetSHA1HashData(password); string shapwd = encrypt.GetSHA1HashData(hashPwd + emp.id); //Get Paremeters from the Database //Status=1, initial status when user created. string TemplateId = "3"; string SpName = emp.Email + "," + emp.Firstname + "," + emp.Lastname + "," + password; DbCommand DCMD = DataAccess.ExecuteNonQueryCMD("MTS_AddEmailMasterEntry", TemplateId, SpName); result = userLogon.ForgotPassword(emp.id, shapwd); } catch (Exception ex) { BaseExceptionHandler.HandleException(ref ex); } return(result); }
public ActionResult AddEmployee(Employee emp) { try { MTSHRDataLayer.Employee data_emp = new MTSHRDataLayer.Employee(); int Empidresult = data_emp.GetEmployeeId(emp.Employee_ID, emp.Email); if (Empidresult != 1) { Encrypt encrypt = new Encrypt(); string password = encrypt.CreateRandomPassword(6); string hashPwd = encrypt.GetSHA1HashData(password); int RetVal = 0; //Get Paremeters from the Database //Status=1, initial status when user created. string TemplateId = "2"; string SpName = emp.Email + "," + emp.Firstname + "," + emp.Lastname + "," + password; DbCommand DCMD = DataAccess.ExecuteNonQueryCMD("MTS_AddEmailMasterEntry", TemplateId, SpName); DbCommand cmd = DataAccess.ExecuteNonQueryCMD("MTS_ADDUSER", emp.Email, hashPwd, emp.Firstname, emp.Lastname, emp.Email, 2, //Default user Role true, //Active 1, //Status false); //Locked RetVal = Convert.ToInt16(cmd.Parameters["@RETURN_VALUE"].Value.ToString()); int result = data_emp.Create(emp.Aadhar, emp.Dateofbirth, emp.Dateofjoin, emp.Designation, emp.Email, emp.Employee_ID, emp.Fathername, emp.Firstname, emp.Gender, emp.Lastname, emp.Maritalstatus, emp.Mobile, emp.Nationality, emp.Pancard, emp.Spousename, emp.PF_AccountNumber, emp.PF_UAN, emp.ESI_Number, emp.DepartmentId, emp.FunctionalRole); if (result > 0) { return(Content("Success")); } else { return(RedirectToAction("Employee", "Employee")); } } else { return(Content("Failed")); } } catch (Exception exec) { BaseExceptionHandler.HandleException(ref exec); } return(Content("Failed")); }
public ActionResult AutoResetPassword(NewUser newUser) { UserData userData = new UserData(); UserLogonData userLogonData = new UserLogonData(); Encrypt encrypt = new Encrypt(); newUser.Password = encrypt.CreateRandomPassword(6); string encryptedpass = encrypt.GetSHA1HashData(newUser.Password); userLogonData.UpdateResetPasswordEmailScheduler(newUser); if (userLogonData.ResetPassword(newUser.UserId, encrypt.GetSHA1HashData(encryptedpass + newUser.UserId)) == true) { return(Content("PWD_RESET_S")); } else { return(Content("PWD_RESET_F")); } }
public ActionResult ForgotPassword(ForgotPasswordModel forget, string Password, string button) { try { if (button == "Cancel") { return(RedirectToAction("Logon", "Account")); } if (ModelState.IsValid) { int status; ForgotPasswordModel forgotPwd = new ForgotPasswordModel(); string secUserAns = forget.inhrtSecurityQuestionModel.SecAns; Int64 secQunId = forget.inhrtSecurityQuestionModel.SelectedSecQsn; encryptSha1 obj = new encryptSha1(); secUserAns = obj.GetSHA1HashData(secUserAns.ToUpper()); string msg = ""; UserLogonData userLogon = new UserLogonData(); LogonUser logonUser = new LogonUser(); logonUser.UserName = forget.UserName; UserDetails userDetails = userLogon.GetUserDeatils(logonUser); if (userDetails.Active != 0 && userDetails.UserId > 0) { status = compareSecAns(forget.UserName, userDetails.SecQunId, userDetails.SecAns, userDetails.Status, userDetails.UserId, secUserAns, secQunId); //1 success 0 incorrect username 2 secQun or ans incorrect if (status == Status.NO_OF_ATM_LOCKED) { forget.inhrtSecurityQuestionModel = initialDDLFillBase(); forget.Message = "User locked for no of attempts"; } else if (status == Status.FIRSTLOGIN) { return(RedirectToAction("logon", "account", new { statusId = Status.FIRSTLOGIN })); } else if (status == Status.PASS) { msg = "FORGET_PASS"; if (userLogon.UpdateStatus(userDetails.UserId, Status.FORGETPWD, msg) == true) { //update cur date in last_pwd_change while ,if pwd expiry ,not change he attempt forget pwd Encrypt encrypt = new Encrypt(); string TempPassword = encrypt.CreateRandomPassword(6); string EncryptedPassword = encrypt.GetSHA1HashData(TempPassword); userLogon.ForgotPassword(userDetails.UserId, encrypt.GetSHA1HashData(EncryptedPassword + userDetails.UserId)); string Templateid = "3"; string spname = "MTS_UserPasswordEmail"; spname = userDetails.Mailid + "," + userDetails.Firstname + "," + userDetails.Lastname + "," + TempPassword; userLogon.MailSending(spname, Templateid); forget.Message = "Password sent your mail id"; return(RedirectToAction("EmailSending", "account")); // for forgot password } else { //forget.Message = resource.GetResource("~/Views/Logon.cshtml", "Failed"); } } else if (status == 2) { forget.inhrtSecurityQuestionModel = initialDDLFillBase(); forget.Message = "The Sec Question or answer you entered is incorrect."; } else { } } else { forget.inhrtSecurityQuestionModel = initialDDLFillBase(); forget.Message = "Invalid user id."; } } else { forget.inhrtSecurityQuestionModel = initialDDLFillBase(); } return(View(forget)); } catch (Exception ex) { throw ex; } }
public RandomPassword() : base(Encrypt.CreateRandomPassword(ro_RandomPasswordLength, CommonLogic.IIF(AppLogic.AppConfig("NewPwdAllowedChars").Length == 0, @"abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ23456789~!@#$%&*()_-={}[]\\|;:\,./?", AppLogic.AppConfig("NewPwdAllowedChars"))), Encrypt.CreateRandomSalt()) { }