//[HttpPost] public ActionResult ResetPassword(string token) { if (token.Contains(" ")) { token = token.Replace(" ", "+"); } string EncryptToken = ""; try { EncryptToken = Convert.ToString(SecurityHelperService.Decrypt(token)); //EncryptToken = token; } catch (Exception ex) { } string[] strlist = EncryptToken.Split(new[] { "~", "##" }, StringSplitOptions.RemoveEmptyEntries); DateTime tokendate = Convert.ToDateTime(strlist[2]); double totaldays = (DateTime.Now - tokendate).TotalDays; if (totaldays > 2) { return(RedirectToAction("TokenExpired", "Account")); } else { IEnumerable <GetEmailId> cm = _lookUpRepository.GetEmailId(int.Parse(strlist[0]), strlist[1]); ViewBag.Username = cm.ElementAt(0).EmailID; ViewBag.role = strlist[1]; return(View()); } }
private void AssignedCookieValue() { try { HttpContext.Session.SetInt32("UserID", Convert.ToInt32(SecurityHelperService.Decrypt(Request.Cookies["UserID"]))); HttpContext.Session.SetString("UserName", Convert.ToString(SecurityHelperService.Decrypt(Request.Cookies["UserName"]))); HttpContext.Session.SetString("Role", Convert.ToString(SecurityHelperService.Decrypt(Request.Cookies["Role"]))); } catch (Exception ex) { throw ex; } }
//[ValidateAntiForgeryToken] public IActionResult ValidateAnchorCompanyLogOn(string Email, string Password) { if (!ReCaptchaPassed( Request.Form["g-recaptcha-response"], // that's how you get it from the Request object _configuration.GetSection("GoogleReCaptcha:SecretKey").Value )) { TempData["InvalidCredential"] = "Captcha verification failed."; return(RedirectToAction("AnchorCompanyLogin", "Account")); } string ActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); Int32? UserLoginID = HttpContext.Session.GetInt32("UserID"); string ErrorMessage = string.Empty; try { Password = SecurityHelperService.Encrypt(Password); User userdata = _userRepository.FindUserName(Email, Password); HttpContext.Session.SetString("Role", "InternalUser"); CookieOptions option = new CookieOptions(); option.Expires = DateTime.Now.AddDays(2); Response.Cookies.Append("RoleAccess", "Anchor Company", option); if (userdata == null) { ViewBag.InvalidCredential = "Enter valid credential"; return(View("AnchorCompanyLogin")); } else { var UserID = userdata.UserID; var UserName = userdata.Name; HttpContext.Session.SetInt32("UserID", UserID); HttpContext.Session.SetString("UserName", UserName); HttpContext.Session.SetString("JWToken", GenerateJWTToken(UserName)); SetCookie(UserID.ToString(), UserName, "InternalUser"); return(RedirectToAction("InvoiceList", "Invoice")); } } catch (Exception ex) { var st = new StackTrace(ex, true); var frame = st.GetFrame(0); int ErrorLine = frame.GetFileLineNumber(); var Result = _CommonRepository.LogManagement(ControllerName, ActionName, ex.Message, ErrorLine, UserLoginID); return(RedirectToAction("ErrorPage", "Common")); } }
public ActionResult SubmitPassword(string Username, string Role, string NewPassword) { var Result = _CommonRepository.UpdatePassword(SecurityHelperService.Encrypt(NewPassword), Username, Role); if (Role == "SuperAdmin") { return(RedirectToAction("SuperAdminLogin", "Account")); } else if (Role == "MasterAdmin") { return(RedirectToAction("AdminLogin", "Account")); } else { return(RedirectToAction("UserLogin", "Account")); //(Role == "Vendor" || Role == "Bank" || Role == "Anchor") } }
/// <summary> /// set the cookie /// </summary> /// <param name="key">key (unique indentifier)</param> /// <param name="value">value to store in cookie object</param> /// <param name="expireTime">expiration time</param> private void SetCookie(string UserID, string UserName, string UserRole) { try { if (Convert.ToString(Request.Cookies.ContainsKey("UserID")) == "False") { var option = new CookieOptions(); option.Expires = DateTime.Now.AddDays(1); Response.Cookies.Append("UserID", SecurityHelperService.Encrypt(UserID), option); Response.Cookies.Append("LoginName", SecurityHelperService.Encrypt(UserName), option); Response.Cookies.Append("Role", SecurityHelperService.Encrypt(UserRole), option); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Set cookie method /// </summary> /// <param name="UserID"></param> /// <param name="UserName"></param> /// <param name="UserRole"></param> public void SetCookie(string UserID, string UserName, string UserRole) { try { if (Convert.ToString(Request.Cookies.ContainsKey("UserID")) == null) { var option = new CookieOptions(); option.Expires = DateTime.Now.AddMinutes(10); Response.Cookies.Append("UserID", UserID, option); Response.Cookies.Append("UserName", SecurityHelperService.Encrypt(UserName), option); Response.Cookies.Append("Role", SecurityHelperService.Encrypt(UserRole), option); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Get cookie method /// </summary> /// <param name="UserID"></param> /// <param name="UserName"></param> /// <param name="UserRole"></param> public void GetCookie(out string UserID, out string UserName, out string UserRole) { UserID = string.Empty; UserName = string.Empty; UserRole = string.Empty; try { if (Request.Cookies["UserID"] == null) { UserID = SecurityHelperService.Decrypt(Request.Cookies["UserID"].ToString()); UserName = SecurityHelperService.Decrypt(Request.Cookies["UserName"].ToString()); UserRole = SecurityHelperService.Decrypt(Request.Cookies["UserRole"].ToString()); } } catch (Exception ex) { throw ex; } }
public ActionResult SendForgetPasswordMail(ForgetPasswordModel objForgetPassword) { string ActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); Int32? UserID = HttpContext.Session.GetInt32("UserID"); string ErrorMessage = string.Empty; var RoleName = ""; FinocartMaster objDatawithSP1 = null; Company objDatawithSP2 = null; User objDatawithSP3 = null; IEnumerable <User> objDatawithSP = _CommonRepository.CheckUserPassword(); IEnumerable <User> objDatawithSP4 = _CommonRepository.CheckUserPassword(); try { var Name = ""; string ID = ""; string randomPassword = _CommonRepository.GeneratePassword(); // string EncryptToken = SecurityHelperService.Encrypt(Token); string EmailID = objForgetPassword.EmailID.Trim(); var data = Encoding.UTF8.GetBytes(objForgetPassword.RoleName); RoleName = Convert.ToBase64String(data); if (objForgetPassword.RoleName == "MasterAdmin") { //IEnumerable<Company> objDatawithSP = _CommonRepository.CheckAdminPassword(); //objDatawithSP = objDatawithSP.Where(x => x.Contact_email == EmailID && x.IsDelete == false); objDatawithSP2 = _CommonRepository.CheckAdminByEmailExists(EmailID); if (objDatawithSP2 != null && (!objDatawithSP2.IsDelete || objDatawithSP2.LoginAttempt == 3)) { Name = objDatawithSP2.Company_name; ID = Convert.ToString(objDatawithSP2.CompanyID); } } if (objForgetPassword.RoleName == "InternalUser") { //IEnumerable<User> objDatawithSP = _CommonRepository.CheckUserPassword(); //objDatawithSP = objDatawithSP.Where(x => x.Email == EmailID && x.IsDelete == true); objDatawithSP3 = _CommonRepository.CheckUserByEmail(EmailID, true); if (objDatawithSP3 != null) { Name = objDatawithSP3.Name; ID = Convert.ToString(objDatawithSP3.UserID); } } if (objForgetPassword.RoleName == "Vendor") { objDatawithSP = objDatawithSP.Where(x => x.Email == EmailID); if (objDatawithSP.Any()) { Name = objDatawithSP.ElementAt(0).Name; ID = Convert.ToString(objDatawithSP.ElementAt(0).UserID); } } if (objForgetPassword.RoleName == "Anchor Company") { objDatawithSP4 = objDatawithSP.Where(x => x.Email == EmailID && x.IsDelete == false); if (objDatawithSP4.Any()) { Name = objDatawithSP4.ElementAt(0).Name; ID = Convert.ToString(objDatawithSP4.ElementAt(0).UserID); } } if (objForgetPassword.RoleName == "SuperAdmin") { objDatawithSP1 = _CommonRepository.CheckSuperAdminByEmail(EmailID, false); if (objDatawithSP1 != null) { Name = objDatawithSP1.Name; ID = Convert.ToString(objDatawithSP1.ID); } } if (Name != "") { string Token = ID + "~" + objForgetPassword.RoleName + "~" + DateTime.Now; string EncryptToken = SecurityHelperService.Encrypt(Token); // var Result = _CommonRepository.UpdatePassword(Password, EmailID, objForgetPassword.RoleName); // if (Result > 0) //{ IEnumerable <GetForgetPasswordMailTemplate> lstAwaitedInvVendorsView = _lookUpRepository.getForgetPasswordMailTemplate(); string path = lstAwaitedInvVendorsView.ElementAt(0).Template; string EMAIL_TOKEN_PAYMENT_LINK = "##$$LOGIN_LINK$$##"; //string paymentLink ="http://*****:*****@@User@@", Name); body = body.Replace("@@ProjectName@@", "Finocart"); body = body.Replace(EMAIL_TOKEN_PAYMENT_LINK, paymentLink); body = body.Replace("http://dotnet.brainvire.com/Finocart/Account/AdminLogin", paymentLink); body = body.Replace("@@Password@@", randomPassword); IEnumerable <LookupDetails> lookupDetails = _lookUpRepository.getLookupDetailByKey("SMTPInfo"); _CommonRepository.SendEmail(lookupDetails, emailToAddress, subject, body, true); TempData["MailSuccess"] = "Mail sent successfully"; // } } else { TempData["WrongMail"] = "Email ID is not valid"; } } catch (Exception ex) { TempData["FailureMessage"] = "We are sorry, something went wrong. Please try again later"; var st = new StackTrace(ex, true); var frame = st.GetFrame(0); int ErrorLine = frame.GetFileLineNumber(); var Result = _CommonRepository.LogManagement(ControllerName, ActionName, ex.Message, ErrorLine, UserID); return(RedirectToAction("ErrorPage", "Common")); } return(RedirectToAction("ForgetPassword", "Account", new { Role = RoleName })); }
public IActionResult ValidateAdminLogOn(string PANNumber, string Password, string IsRemember) { if (!ReCaptchaPassed( Request.Form["g-recaptcha-response"], // that's how you get it from the Request object _configuration.GetSection("GoogleReCaptcha:SecretKey").Value )) { TempData["InvalidCredential"] = "Captcha verification failed."; return(RedirectToAction("AdminLogin", "Account")); } string pw = SecurityHelperService.Decrypt("9b1L+4cRvb5EYXkEw8dl3bgkBFnKqjSQ"); string InputCredential = PANNumber; string Controller = ""; string ActionName = ""; Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match = regex.Match(InputCredential); Password = SecurityHelperService.Encrypt(Password); AdminLoginModel objDatawithSP = _adminRepository.FindName(PANNumber, Password); if (objDatawithSP == null) { string strLockRes = _adminRepository.LockedAdminUser(PANNumber); TempData["InvalidCredential"] = strLockRes; return(RedirectToAction("AdminLogin", "Account")); } else { var AdminID = objDatawithSP.CompanyID; var AdminName = objDatawithSP.ContactPersonName; var InternalRole = objDatawithSP.Role; var companyname = objDatawithSP.Name; CookieOptions option = new CookieOptions(); option.Expires = DateTime.Now.AddDays(2); Response.Cookies.Append("RoleAccess", "AdminLogin", option); TempData["InternalRole"] = InternalRole; HttpContext.Session.SetInt32("UserID", AdminID); HttpContext.Session.SetString("LoginName", AdminName); HttpContext.Session.SetString("Role", "MasterAdmin"); HttpContext.Session.SetString("CompanyType", InternalRole); HttpContext.Session.SetString("Companyname", companyname); HttpContext.Session.SetString("JWToken", GenerateJWTToken(AdminName)); //HttpContext.Session.SetString("RoleAccess", RoleAccess); if (objDatawithSP.IsTemporaryPassword == false) { TempData["Role"] = "MasterAdmin"; if (IsRemember == "1") { SetCookie(AdminID.ToString(), AdminName, "MasterAdmin"); Response.Cookies.Append("PANNumber", PANNumber, option); } return(RedirectToAction("UserList", "User")); } else { var data = Encoding.UTF8.GetBytes("MasterAdmin"); var Role = Convert.ToBase64String(data); Controller = "Common"; ActionName = "ChangePassword"; HttpContext.Session.SetString("Email", objDatawithSP.PANNumber); if (IsRemember == "1") { SetCookie(AdminID.ToString(), AdminName, "MasterAdmin"); Response.Cookies.Append("PANNumber", PANNumber, option); } return(RedirectToAction(ActionName, Controller, new { RoleName = Role })); } } }
public IActionResult ValidateSuperAdminLogOn(string EmailID, string Password, string IsRemember) { //EmailID = "*****@*****.**"; if (!ReCaptchaPassed( Request.Form["g-recaptcha-response"], // that's how you get it from the Request object _configuration.GetSection("GoogleReCaptcha:SecretKey").Value )) { TempData["InvalidCredential"] = "Captcha verification failed."; return(RedirectToAction("SuperAdminLogin", "Account")); } string ActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); Int32? UserLoginID = HttpContext.Session.GetInt32("UserID"); string ErrorMessage = string.Empty; try { Password = SecurityHelperService.Encrypt(Password); FinocartMaster objDatawithSP = _SuperAdminRepository.ValidateLogin(EmailID, Password); HttpContext.Session.SetString("Role", "SuperAdmin"); CookieOptions option = new CookieOptions(); option.Expires = DateTime.Now.AddDays(2); Response.Cookies.Append("RoleAccess", "SuperAdmin", option); if (objDatawithSP == null) { TempData["InvalidCredential"] = "Enter valid credential"; return(RedirectToAction("SuperAdminLogin", "Account")); } else { var UserID = objDatawithSP.ID; var UserName = objDatawithSP.Name; HttpContext.Session.SetInt32("UserID", UserID); HttpContext.Session.SetString("LoginName", UserName); HttpContext.Session.SetString("JWToken", GenerateJWTToken(UserName)); if (IsRemember == "1") { SetCookie(UserID.ToString(), UserName, "SuperAdmin"); Response.Cookies.Append("EmailID", EmailID, option); } var Res = _CommonRepository.AuditTrailLog("Login", "Super Admin Login", UserID, 0); if (objDatawithSP.IsTemporaryPassword == false) { TempData["Role"] = "SuperAdmin"; return(RedirectToAction("SuperAdminDashBoard", "AnchorCompany")); } else { var data = Encoding.UTF8.GetBytes("SuperAdmin"); var Role = Convert.ToBase64String(data); HttpContext.Session.SetString("Email", objDatawithSP.EmailId); return(RedirectToAction("ChangePassword", "Common", new { RoleName = Role })); } } } catch (Exception ex) { var st = new StackTrace(ex, true); var frame = st.GetFrame(0); int ErrorLine = frame.GetFileLineNumber(); var Result = _CommonRepository.LogManagement(ControllerName, ActionName, ex.Message, ErrorLine, UserLoginID); return(RedirectToAction("ErrorPage", "Common")); } }
public IActionResult ValidateUserLogOn(string Email, string Password, string IsRemember) { if (!ReCaptchaPassed( Request.Form["g-recaptcha-response"], // that's how you get it from the Request object _configuration.GetSection("GoogleReCaptcha:SecretKey").Value )) { TempData["InvalidCredential"] = "Captcha verification failed."; return(RedirectToAction("UserLogin", "Account")); } string ControllerActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); Int32? LoginUserID = HttpContext.Session.GetInt32("UserID"); string ErrorMessage = string.Empty; try { string pw = SecurityHelperService.Decrypt("8qLsuVEBHnIzavnjCKcC5g=="); Password = SecurityHelperService.Encrypt(Password); UserLoginModel userModel = _venderRepository.validateUser(Email, Password); string Controller = ""; string ActionName = ""; HttpContext.Session.SetString("Role", "InternalUser"); if (userModel == null) { string strLockRes = _adminRepository.LockedUser(Email); TempData["InvalidCredential"] = strLockRes; //TempData["InvalidCredential"] = "Enter valid credential"; return(RedirectToAction("UserLogin", "Account")); } else { var UserID = Convert.ToInt32(userModel.UserID); var UserName = userModel.Name; var CompanyId = userModel.CompanyID; var RoleAccess = userModel.RoleAccess; var Companyname = userModel.Companyname; Response.Cookies.Delete("RoleAccess"); CookieOptions option = new CookieOptions(); option.Expires = DateTime.Now.AddDays(2); Response.Cookies.Append("RoleAccess", RoleAccess, option); HttpContext.Session.SetInt32("UserID", UserID); HttpContext.Session.SetString("LoginName", UserName); HttpContext.Session.SetInt32("CompanyID", CompanyId); HttpContext.Session.SetString("RoleAccess", RoleAccess); HttpContext.Session.SetString("Companyname", Companyname); HttpContext.Session.SetString("JWToken", GenerateJWTToken(UserName)); if (IsRemember == "1") { SetCookie(UserID.ToString(), UserName, "InternalUser"); Response.Cookies.Append("Email", Email, option); } var Res = _CommonRepository.AuditTrailLog("LoginPage", "LoginPage", UserID, 0); if (userModel.IsTemporaryPassword == false) { if (RoleAccess == "Vendor Company") { Controller = "Vendor"; ActionName = "VendorDashboardMain"; } if (RoleAccess == "Anchor Company") { var lstchecklimit = _companyRepository.CheckSetLimit(CompanyId); string PercentageRate = Convert.ToString(lstchecklimit.ElementAt(0).PercentageRate); string PaymentDays = Convert.ToString(lstchecklimit.ElementAt(0).PaymentDays); //if (PercentageRate != "" && PaymentDays != "") //{ Controller = "AnchorCompany"; ActionName = "AnchorDashboard"; //} //else //{ // //Controller = "AnchorCompany"; // //ActionName = "AnchorDashboard"; // Controller = "AnchorCompany"; // ActionName = "SetLimit"; //} } if (RoleAccess == "Both") { Controller = "AnchorCompany"; ActionName = "AnchorDashboard"; } if (RoleAccess == "Bank") { Controller = "BankCompany"; ActionName = "BankDashboard"; } return(RedirectToAction(ActionName, Controller)); } else { var data = Encoding.UTF8.GetBytes("InternalUser"); var Role = Convert.ToBase64String(data); HttpContext.Session.SetString("Email", userModel.Email); Controller = "Common"; ActionName = "ChangePassword"; SetCookie(UserID.ToString(), UserName, Role); return(RedirectToAction(ActionName, Controller, new { RoleName = Role })); } } } catch (Exception ex) { var st = new StackTrace(ex, true); var frame = st.GetFrame(0); int ErrorLine = frame.GetFileLineNumber(); var Result = _CommonRepository.LogManagement(ControllerName, ControllerActionName, ex.Message, ErrorLine, LoginUserID); return(RedirectToAction("ErrorPage", "Common")); } }
public ActionResult AddUser(UserModel objUserPage) { string ActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); Int32? UserID = HttpContext.Session.GetInt32("UserID"); string ErrorMessage = string.Empty; try { string randomPassword = _CommonRepository.GeneratePassword(); if (objUserPage.UserID == 0) { objUserPage.Password = SecurityHelperService.Encrypt(randomPassword); } Int32? UserId = HttpContext.Session.GetInt32("UserID"); Int32? AccessViewId = objUserPage.AccessViewID; string CompanyName = HttpContext.Session.GetString("Companyname"); objUserPage.CreatedBy = UserId; objUserPage.UpdatedBy = UserId; var Result = _Userepository.InsertUpdateUserRecord(objUserPage); if (objUserPage.UserID == 0) { if (Result > 0) { //string Template = string.Empty; IEnumerable <GetUserMailTemplate> lstAwaitedInvVendorsView = _lookUpRepository.getUserMailTemplate(AccessViewId); string path = lstAwaitedInvVendorsView.ElementAt(0).Template; string EMAIL_TOKEN_PAYMENT_LINK = "##$$PAYMENT_LINK$$##"; string paymentLink = "http://dotnet.brainvire.com/Finocart/Account/UserLogin";///change url string emailToAddress = objUserPage.Email; string subject = "User registration"; string body = path; body = body.Replace("@@Panno@@", objUserPage.Email); body = body.Replace("@@UserName@@", objUserPage.Name); body = body.Replace("@@CompanyName@@", CompanyName); body = body.Replace("@@ProjectName@@", "Finocart"); body = body.Replace(EMAIL_TOKEN_PAYMENT_LINK, paymentLink); body = body.Replace("@@Password@@", randomPassword); IEnumerable <LookupDetails> lookupDetails = _lookUpRepository.getLookupDetailByKey("SMTPInfo"); _CommonRepository.SendEmail(lookupDetails, emailToAddress, subject, body, true); User objDatawithSP = _CommonRepository.CheckUserByEmail(objUserPage.Email, false); if (objDatawithSP != null) { string DescriptionMessage = "Congratulations your registered on the Finocart Portal. Now you can access the portal and create your users "; var Result1 = _Userepository.AddUserNotificationMessage(objDatawithSP.UserID, DescriptionMessage, null, UserId); } } TempData["AddResult"] = Result; } else { TempData["UpdateResult"] = Result; } } catch (Exception ex) { var st = new StackTrace(ex, true); var frame = st.GetFrame(0); int ErrorLine = frame.GetFileLineNumber(); var Result = _CommonRepository.LogManagement(ControllerName, ActionName, ex.Message, ErrorLine, UserID); return(RedirectToAction("ErrorPage", "Common")); TempData["FailureMessage"] = "We are sorry, something went wrong. Please try again later"; } return(RedirectToAction("UserList", "User")); }
public IActionResult updateNewPassword(ChangePasswordModel changePassword) { string ActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); Int32? UserID = HttpContext.Session.GetInt32("UserID"); string ErrorMessage = string.Empty; var lstEmailIDofBank = _companyRepository.GetAnchorEmail(Convert.ToString(changePassword.UserId)); changePassword.Email = lstEmailIDofBank.ElementAt(0).Contact_email; try { var Result = ""; var Actions = ""; changePassword.NewPassword = SecurityHelperService.Encrypt(changePassword.NewPassword); changePassword.OldPassword = SecurityHelperService.Encrypt(changePassword.OldPassword); var data = Encoding.UTF8.GetBytes(changePassword.Role); var Role = Convert.ToBase64String(data); if (HttpContext.Session.GetInt32("UserID") != null) { if (changePassword.Role == "InternalUser") { Actions = "UserLogin"; User objDatawithSP = _empRepository.CheckUser(changePassword.Email, changePassword.OldPassword); if (objDatawithSP != null) { Result = objDatawithSP.Password; } } if (changePassword.Role == "MasterAdmin") { Actions = "AdminLogin"; Company objDatawithSP = _empRepository.CheckAdmin(changePassword.Email, changePassword.OldPassword); if (objDatawithSP != null) { Result = objDatawithSP.Password; } } if (changePassword.Role == "SuperAdmin") { Actions = "SuperAdminLogin"; FinocartMaster objDatawithSP = _empRepository.CheckSuperAdmin(changePassword.Email, changePassword.OldPassword); if (objDatawithSP != null) { Result = objDatawithSP.Password; } } if (Result != "") { var Data = _empRepository.UpdateNewPassword(changePassword); } else { TempData["WrongPassword"] = "******"; return(RedirectToAction("ChangePassword", "Common", new { RoleName = Role })); } if (Result != "") { string emailToAddress = lstEmailIDofBank.ElementAt(0).Contact_email; string AnchorName = lstEmailIDofBank.ElementAt(0).Contact_Name; string BankName = HttpContext.Session.GetString("LoginName"); string Template = string.Empty; int Id = 1; IEnumerable <GetChangePasswordMailTemplate> lstAwaitedInvVendorsView = _companyRepository.GetChangePasswordMailTemplate(Template); string path = lstAwaitedInvVendorsView.ElementAt(0).Template; //string path = ""; string subject = "Change Password"; string body = path; body = body.Replace("@@User@@", AnchorName); body = body.Replace("@@BankName@@", BankName); body = body.Replace("@@mentiondateandtime", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")); IEnumerable <LookupDetails> lookupDetails = _lookUpRepository.getLookupDetailByKey("SMTPInfo"); _CommonRepository.SendEmail(lookupDetails, emailToAddress, subject, body, true); } return(RedirectToAction(Actions, "Account")); } else { return(RedirectToAction("ChangePassword", "Common", new { RoleName = Role })); } } catch (Exception ex) { var st = new StackTrace(ex, true); var frame = st.GetFrame(0); int ErrorLine = frame.GetFileLineNumber(); var Result = _CommonRepository.LogManagement(ControllerName, ActionName, ex.Message, ErrorLine, UserID); return(RedirectToAction("ErrorPage", "Common")); } }
public IActionResult setChangePassword(ChangePasswordModel objChangePassword) { string ActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); Int32? UserID = HttpContext.Session.GetInt32("UserID"); string ErrorMessage = string.Empty; try { //string pw = SecurityHelperService.Decrypt("ueNl4Gl98pKy3m0G6CaqBsi6jSC58DX8"); var Result = ""; var Actions = ""; objChangePassword.NewPassword = SecurityHelperService.Encrypt(objChangePassword.NewPassword); objChangePassword.OldPassword = SecurityHelperService.Encrypt(objChangePassword.OldPassword); var data = Encoding.UTF8.GetBytes(objChangePassword.Role); var Role = Convert.ToBase64String(data); if (HttpContext.Session.GetInt32("UserID") != null) { if (objChangePassword.Role == "InternalUser") { Actions = "UserLogin"; //IEnumerable<User> objDatawithSP = _empRepository.CheckUserPassword(); //objDatawithSP = objDatawithSP.Where(x => x.Password == objChangePassword.OldPassword && x.Email == objChangePassword.Email); User objDatawithSP = _empRepository.CheckUser(objChangePassword.Email, objChangePassword.OldPassword); if (objDatawithSP != null) { Result = objDatawithSP.Password; } } if (objChangePassword.Role == "MasterAdmin") { Actions = "AdminLogin"; //IEnumerable<Company> objDatawithSP = _empRepository.CheckAdminPassword(); ////objDatawithSP = objDatawithSP.Where(x => x.Password == objChangePassword.OldPassword && (x.Email == objChangePassword.Email || x.PANNumber == objChangePassword.Email)); //objDatawithSP = objDatawithSP.Where(x => x.Password == objChangePassword.OldPassword && x.Pan_number == objChangePassword.Email); Company objDatawithSP = _empRepository.CheckAdmin(objChangePassword.Email, objChangePassword.OldPassword); if (objDatawithSP != null) { Result = objDatawithSP.Password; } } if (objChangePassword.Role == "SuperAdmin") { Actions = "SuperAdminLogin"; //IEnumerable<FinocartMaster> objDatawithSP = _empRepository.CheckSuperAdminPassword(); //objDatawithSP = objDatawithSP.Where(x => x.Password == objChangePassword.OldPassword && x.EmailId == objChangePassword.Email); FinocartMaster objDatawithSP = _empRepository.CheckSuperAdmin(objChangePassword.Email, objChangePassword.OldPassword); if (objDatawithSP != null) { Result = objDatawithSP.Password; } } if (Result != "") { var Data = _empRepository.UpdateNewPassword(objChangePassword); return(RedirectToAction(Actions, "Account")); } else { TempData["WrongPassword"] = "******"; return(RedirectToAction("ChangePassword", "Common", new { RoleName = Role })); } } else { return(RedirectToAction("ChangePassword", "Common", new { RoleName = Role })); } } catch (Exception ex) { var st = new StackTrace(ex, true); var frame = st.GetFrame(0); int ErrorLine = frame.GetFileLineNumber(); var Result = _CommonRepository.LogManagement(ControllerName, ActionName, ex.Message, ErrorLine, UserID); return(RedirectToAction("ErrorPage", "Common")); } }