/// <summary> /// Method Name : CreatePassword /// Author : Sanket Prajapati /// Creation Date : 5 Dec 2017 /// Purpose : For Save Customer Password /// Revision : /// </summary> public async Task <ServiceResponse> CreatePassword(string StrCreatePassword, string StrVerifyPassword) { string errorMessage = string.Empty; APIResponse <CustomerModel> response; bool isTermAgree = false; CreatePasswordModel createPasswordModel = new CreatePasswordModel { CreatePassword = StrCreatePassword.Trim(), VerifyPassword = StrVerifyPassword.Trim() }; errorMessage = loginValidateServices.ValidateCreatePasswordModel(createPasswordModel); if (string.IsNullOrEmpty(errorMessage)) { response = await PutCustomerVerificationDataAsync(createPasswordModel); errorMessage = response.Message; if (response.STATUS) { await GetCustomerProfileData(UtilityPCL.LoginCustomerData); isTermAgree = Convert.ToBoolean(UtilityPCL.LoginCustomerData.TermsAgreed); errorMessage = string.Empty; } } return(getServiceResponse(errorMessage, isTermAgree)); }
public ActionResult LeadCreatePassword(string sToken, string sFirstName, string sLastName, string sEmail) { var oModel = new CreatePasswordModel { RawToken = sToken, FirstName = sFirstName, LastName = sLastName, UserName = sEmail, BrokerLeadStr = "yes", }; return(View("CreatePassword", oModel)); } // LeadCreatePassword
public async Task <IHttpActionResult> CreatePassword(CreatePasswordModel model) { // this will only work if current password is null (via signup flow) if (!String.IsNullOrWhiteSpace(CurrentUser.Password)) { return(BadRequest("The password has already been created.")); } if (model == null || !IsValidPassword(model.Password)) { return(BadRequest(_invalidPasswordMessage)); } await ChangePassword(CurrentUser, model.Password); ExceptionlessClient.Default.CreateFeatureUsage("Create Password").AddObject(CurrentUser).Submit(); return(Ok()); }
/// <summary> /// Method Name : ValidateCreatePasswordModel /// Author : Hiren Patel /// Creation Date : 5 Dec 2017 /// Purpose : Validate Create Password model. /// Revision : /// </summary> /// <param name="createPasswordModel"></param> /// <returns></returns> public string ValidateCreatePasswordModel(CreatePasswordModel createPasswordModel) { string errorMessage = string.Empty; if (string.IsNullOrEmpty(createPasswordModel.CreatePassword)) { errorMessage = string.Format(Resource.msgFieldRequired, Resource.msgRequiredCreatePassword); } else if (string.IsNullOrEmpty(createPasswordModel.VerifyPassword)) { errorMessage = string.Format(Resource.msgFieldRequired, Resource.msgRequiredConfirmPassword); } else if (createPasswordModel.VerifyPassword != createPasswordModel.CreatePassword) { errorMessage = Resource.msgPasswordMismatch; } return(errorMessage); }
public ActionResult CreatePassword(string token) { var oModel = new CreatePasswordModel { RawToken = token, }; if (oModel.IsTokenValid) { log.Debug("AccountController.CreatePassword: token received {0}.", token); try { CustomerDetailsActionResult ar = this.serviceClient.Instance.LoadCustomerByCreatePasswordToken(oModel.Token); if (ar.Value.CustomerID > 0) { oModel.FirstName = ar.Value.FirstName; oModel.LastName = ar.Value.LastName; oModel.UserName = ar.Value.Email; log.Debug( "AccountController.CreatePassword: token received {0} -> user {1} ({2}, {3}).", token, oModel.FirstName, ar.Value.CustomerID, oModel.UserName ); return(View(oModel)); } // if log.Debug("AccountController.CreatePassword: token received {0} -> no user found.", token); } catch (Exception e) { log.Alert(e, "Failed to check create password token '{0}'.", token); } // try } else { log.Warn("AccountController.CreatePassword: invalid token received {0}.", token); } return(RedirectToAction("LogOn", "Account", new { Area = "" })); } // CreatePassword
/// <summary> /// Method Name : PutCustomerVerificationDataAsync /// Author : Vivek Bhavsar /// Creation Date : 23 Jan 2018 /// Purpose : Sub method created(code refactoring) to update verification data /// Revision : /// </summary> /// <param name="createPasswordModel"></param> /// <returns></returns> private async Task <APIResponse <CustomerModel> > PutCustomerVerificationDataAsync(CreatePasswordModel createPasswordModel) { APIResponse <CustomerModel> response; PutCreatePasswordModel putCreatePasswordModel = new PutCreatePasswordModel(); putCreatePasswordModel.PasswordHash = createPasswordModel.CreatePassword; putCreatePasswordModel.PasswordSalt = createPasswordModel.CreatePassword; putCreatePasswordModel.CustomerId = UtilityPCL.LoginCustomerData.CustomerId; response = await loginAPIServies.PutCustomerVerificationData(putCreatePasswordModel); return(response); }
public JsonResult CustomerCreatePassword(CreatePasswordModel model) { var customerIp = RemoteIp(); if (!ModelState.IsValid) { log.Debug( "Customer create password attempt from remote IP {0}: model state is invalid, list of errors:", customerIp ); foreach (var val in ModelState.Values) { if (val.Errors.Count < 1) { continue; } foreach (var err in val.Errors) { log.Debug("Model value '{0}' with error '{1}'.", val.Value, err.ErrorMessage); } } // for each value log.Debug("End of list of errors."); return(Json(new { success = false, errorMessage = "Failed to set a password.", }, JsonRequestBehavior.AllowGet)); } // if var pu = new PasswordUtility(CurrentValues.Instance.PasswordHashCycleCount); log.Debug( "Customer create password attempt from remote IP {0} received: {1}...", customerIp, pu.Generate(model.UserName, model.Password) ); CustomerOriginEnum origin = UiCustomerOrigin.Get().GetOrigin(); SetPasswordActionResult spar; try { spar = this.serviceClient.Instance.SetCustomerPasswordByToken( model.Token, origin, new DasKennwort(model.Password), new DasKennwort(model.signupPass2), model.IsBrokerLead, customerIp ); } catch (Exception e) { log.Warn(e, "Failed to set new password for user '{0}'.", model.UserName); return(Json(new { success = false, errorMessage = "Failed to set a password.", }, JsonRequestBehavior.AllowGet)); } // try if (!string.IsNullOrWhiteSpace(spar.ErrorMsg)) { log.Warn( "Failed to set a password for user name {0}, error message returned: {1}.", model.UserName, spar.ErrorMsg ); return(Json(new { success = false, errorMessage = spar.ErrorMsg, }, JsonRequestBehavior.AllowGet)); } // if if (spar.UserID <= 0) { log.Warn("Failed to set a password (returned user id is 0) for user name {0}.", model.UserName); return(Json(new { success = false, errorMessage = "Failed to set a password.", }, JsonRequestBehavior.AllowGet)); } // if if (spar.IsBroker) { BrokerHelper.SetAuth(spar.Email); return(Json(new { success = true, errorMessage = string.Empty, broker = true, })); } // if is broker if (spar.SessionID != 0) { Session["UserSessionId"] = spar.SessionID; } if (string.IsNullOrWhiteSpace(spar.ErrorMsg)) { model.SetCookie(LogOnModel.Roles.Customer); this.context.SetSessionOrigin(origin); } // if return(Json(new { success = string.IsNullOrWhiteSpace(spar.ErrorMsg), errorMessage = spar.ErrorMsg, broker = false, }, JsonRequestBehavior.AllowGet)); } // CustomerCreatePassword
} // constructor public ActionResult Index( string sourceref = "", string shop = "", string ezbobab = "", string invite = "", string bloken = "", string sourceref_time = "", string lead_data = "", string alibaba_id = "", string baba_id = "", string furl = "", string fsource = "", string fmedium = "", string fterm = "", string fcontent = "", string fname = "", string fdate = "", string rurl = "", string rsource = "", string rmedium = "", string rterm = "", string rcontent = "", string rname = "", string rdate = "", string loan_amount = "", string loan_period = "" ) { ms_oLog.Debug("HomeController.Index(sourceref = {0}, sourceref_time = {1})", sourceref, sourceref_time); ms_oLog.Debug("fulr = {0},fsource = {1},fmedium = {2},fterm = {3},fcontent = {4},fname = {5},fdate = {6},", furl, fsource, fmedium, fterm, fcontent, fname, fdate); ms_oLog.Debug("rulr = {0},rsource = {1},rmedium = {2},rterm = {3},rcontent = {4},rname = {5},rdate = {6},", rurl, rsource, rmedium, rterm, rcontent, rname, rdate); if ((Request != null) && (Request.Url != null)) { ms_oLog.Debug("Full request URL - begin:\n{0}\nFull request URL - end.", Request.Url); } Session["Shop"] = shop; CreatePasswordModel oCreatePassword = null; if (!string.IsNullOrWhiteSpace(bloken)) { oCreatePassword = SetBrokerLeadData(bloken); } AddCookie(sourceref, "sourceref", 3); AddCookie(invite, "invite", 3); AddCookie(ezbobab, "ezbobab", 3); AddCookie(sourceref_time, "sourceref_time", 3); AddCookie(!string.IsNullOrWhiteSpace(baba_id) ? baba_id : alibaba_id, "alibaba_id", 6); AddCookie(furl, "furl", 6); AddCookie(fsource, "fsource", 6); AddCookie(fmedium, "fmedium", 6); AddCookie(fterm, "fterm", 6); AddCookie(fcontent, "fcontent", 6); AddCookie(fname, "fname", 6); AddCookie(fdate, "fdate", 6); const int week = 7; AddCookie(rurl, "rurl", days: week, isDay: true); AddCookie(rsource, "rsource", days: week, isDay: true); AddCookie(rmedium, "rmedium", days: week, isDay: true); AddCookie(rmedium, "rmedium", days: week, isDay: true); AddCookie(rterm, "rterm", days: week, isDay: true); AddCookie(rcontent, "rcontent", days: week, isDay: true); AddCookie(rname, "rname", days: week, isDay: true); AddCookie(rdate, "rdate", days: week, isDay: true); AddCookie(loan_amount, "loan_amount", 6); AddCookie(loan_period, "loan_period", 6); ParseLeadData(lead_data); if (oCreatePassword != null) { return(RedirectToAction("LeadCreatePassword", "Account", new { sToken = oCreatePassword.RawToken, sFirstName = oCreatePassword.FirstName, sLastName = oCreatePassword.LastName, sEmail = oCreatePassword.UserName, })); } // if return(RedirectToActionPermanent("Index", User.Identity.IsAuthenticated ? "Profile" : "Wizard", new { Area = "Customer" })); } // Index
} // ActivateStore private CreatePasswordModel SetBrokerLeadData(string sBrokerLeadToken) { CreatePasswordModel oResult = null; new WizardBrokerLeadModel(Session).Unset(); ms_oLog.Debug("Broker token observed in sign up request: {0}, processing...", sBrokerLeadToken); try { var oServiceClient = new ServiceClient(); BrokerLeadDetailsActionResult bld = oServiceClient.Instance.BrokerLeadCheckToken(sBrokerLeadToken); if (bld.LeadID > 0) { ms_oLog.Debug( "Broker lead found: {0} {1} ({2}, {3}), customer id: {4}", bld.FirstName, bld.LastName, bld.LeadID, bld.LeadEmail, bld.CustomerID ); if (bld.CustomerID > 0) { oResult = new CreatePasswordModel { RawToken = sBrokerLeadToken, FirstName = bld.FirstName, LastName = bld.LastName, UserName = bld.LeadEmail, }; } else { // ReSharper disable ObjectCreationAsStatement // This constructor saves data to Session. new WizardBrokerLeadModel( Session, bld.LeadID, bld.LeadEmail, bld.FirstName, bld.LastName, false ); // ReSharper restore ObjectCreationAsStatement } } else { ms_oLog.Debug("No lead found."); } } catch (Exception e) { ms_oLog.Warn(e, "Something went terribly not so good while processing broker lead token {0}.", sBrokerLeadToken); } // try ms_oLog.Debug("Broker token observed in sign up request: {0}, processing complete.", sBrokerLeadToken); return(oResult); } // SetBrokerLeadData