public ActionResult CheckEmail(ResetEmailOldViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { SecurityVerify.Verify <ResetEmailOldVerification>(model.Email.Replace("@", "_"), null, model.Code); } catch (ApplicationException ex) { ModelState.AddModelError("", ex.Message); return(View(model)); } catch (Exception) { ModelState.AddModelError("", GeneralResource.SaveFailed); return(View(model)); } var emailToken = SecurityVerify.SendCode <ResetEmailOldTokenVerification>(model.Email.Replace("@", "_"), model.Email); var timeTicks = Encrypts.GenerateTicksInTenTime(); var token = HttpUtility.UrlEncode(PasswordHasher.HashPassword(emailToken + timeTicks)); return(RedirectToAction("ResetEmail", new { token })); }
public async Task <string> SendCheckEmailCode(SendEmailCodeViewModel model) { if (!ModelState.IsValid) { string resultmessage = ""; foreach (string error in ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage))) { resultmessage += error + Environment.NewLine; } return(new ResponesResult(false, resultmessage).ToString()); } var account = await new AccountComponent().GetAccountByIdAsync(AccountInfo.Id); if (!account.Email.Equals(model.Email, StringComparison.CurrentCultureIgnoreCase)) { return(new ResponesResult(false, AccountResetEmail.EmailNotMatch).ToString()); } var code = SecurityVerify.SendCode <ResetEmailOldVerification>(account.Email.Replace("@", "_"), account.Email); if (string.IsNullOrEmpty(code))//一分钟内发送过 { return(new ResponesResult(false, GeneralResource.OptionTooFrequent).ToString()); } var subject = AccountResetEmail.EmailSubject; var content = string.Format(AccountResetEmail.OriginalEmailContent, code); await new EmailAgent().SendAsync(model.Email, subject, content); return(new ResponesResult(true).ToString()); }
public async Task <string> SendFirstSettingEmailCode(SendEmailCodeViewModel model) { if (!ModelState.IsValid) { string resultmessage = ""; foreach (string error in ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage))) { resultmessage += error + Environment.NewLine; } return(new ResponesResult(false, resultmessage).ToString()); } if (await new AccountComponent().CheckEmailBind(AccountInfo.Id, model.Email)) { return(new ResponesResult(false, AccountFirstSetting.EmailBindByOtherAccount).ToString()); } var code = SecurityVerify.SendCode <FirstSettingEmailVerification>(model.Email.Replace("@", "_"), model.Email); if (string.IsNullOrEmpty(code))//一分钟内发送过 { return(new ResponesResult(false, GeneralResource.OptionTooFrequent).ToString()); } var subject = AccountFirstSetting.EmailSubject; var content = string.Format(AccountFirstSetting.EmailContent, code); await new EmailAgent().SendAsync(model.Email, subject, content); return(new ResponesResult(true).ToString()); }
public void SendSignupSMS(string cellphone, int countryId, string possn) { var country = new CountryComponent().GetById(countryId); if (country == null) { throw new CommonException(10000, Resources.国家不存在); } var posDac = new POSDAC(); var pos = posDac.GetBySn(possn); if (pos == null) { throw new GeneralException(Resources.SN码不存在); } if (pos.Status) { throw new GeneralException(Resources.POSHasBoundOtherAccount); } Dictionary <string, string> dic = new Dictionary <string, string> { { "Cellphone", cellphone }, { "CountryId", countryId.ToString() }, { "FiatCurrency", country.FiatCurrency }, { "PhoneCode", country.PhoneCode } }; var verifier = new FiiiPosRegisterVerifier(); SecurityVerify.SendCode(verifier, SystemPlatform.FiiiPOS, $"{countryId}{cellphone}", $"{country.PhoneCode}{cellphone}"); verifier.CacheRegisterModel(SystemPlatform.FiiiPOS, $"{countryId}{cellphone}", dic); }
public void SendUpdateNewEmailCode(Guid accountId, string emailAddress) { var dac = new MerchantAccountDAC(); var account = dac.GetById(accountId); if (account.Email == emailAddress) { throw new CommonException(ReasonCode.ORIGIN_NEW_EMAIL_SAME, Resources.新邮箱不能和原来的邮箱一致); } var accountByEmail = dac.GetByEmail(emailAddress); if (accountByEmail != null && accountByEmail.Id != accountId) { throw new CommonException(ReasonCode.EMAIL_BINDBYOTHER, Resources.此邮箱已经绑定到其他邮箱); } string subject = Resources.验证码邮箱标题; SecurityVerify.SendCode(new UpdateEmailNewVerifier(), SystemPlatform.FiiiPOS, accountId.ToString(), emailAddress, subject); var model = SecurityVerify.GetModel <FiiiPosUpdateEmailVerify>(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPOS, accountId.ToString()); model.NewEmail = emailAddress; SecurityVerify.SetModel(new CustomVerifier("UpdateEmail"), SystemPlatform.FiiiPOS, accountId.ToString(), model); }
public void SendModifyCellphoneSMS(Guid accountId, string cellphone) { MerchantAccount account = new MerchantAccountDAC().GetById(accountId); Country country = new CountryComponent().GetById(account.CountryId); //加上区号 cellphone = $"{country.PhoneCode}{cellphone}"; SecurityVerify.SendCode(new ModifyCellphoneVerifier(), SystemPlatform.FiiiPOS, account.Id.ToString(), cellphone); }
/// <summary> /// 发送注册验证码 /// </summary> /// <param name="countryId"></param> /// <param name="cellphone"></param> public void SendRegisterCode(int countryId, string cellphone) { if (!AccountUseable(countryId, cellphone)) { throw new CommonException(ReasonCode.ACCOUNT_EXISTS, Format(MessageResources.AccountAlreadyExist, cellphone)); } var country = new CountryComponent().GetById(countryId); SecurityVerify.SendCode(new RegisterCellphoneVerifier(), SystemPlatform.FiiiPay, $"{countryId}:{cellphone}", $"{country.PhoneCode}{cellphone}"); }
/// <summary> /// 发送验证新邮箱的验证码 /// </summary> /// <param name="email"></param> public void SendUpdateNewEmailCode(UserAccount user, string email) { if (user.Email == email) { throw new CommonException(ReasonCode.ORIGIN_NEW_EMAIL_SAME, MessageResources.NewMailOldSame); } string subject = Resources.VerificationCodoEmailTitle; SecurityVerify.SendCode(new UpdateEmailNewVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), email, subject); }
public void SendUpdateCellphoneNewCode(UserAccount user, string newCellphone) { if (new UserAccountDAC().GetByCountryIdAndCellphone(user.CountryId, newCellphone) != null) { throw new CommonException(ReasonCode.PhoneNumber_Exist, MessageResources.MobilePhoneHasReg); } var country = new CountryComponent().GetById(user.CountryId); SecurityVerify.SendCode(new UpdateCellphoneNewVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), $"{country.PhoneCode}{newCellphone}"); }
/// <summary> /// 发送登录验证码 /// </summary> /// <param name="countryId"></param> /// <param name="cellphone"></param> public void SendLoginCode(int countryId, string cellphone) { if (AccountUseable(countryId, cellphone)) { throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, MessageResources.AccountNotFound); } var country = new CountryComponent().GetById(countryId); SecurityVerify.SendCode(new LoginCellphoneVerifier(), SystemPlatform.FiiiPay, $"{countryId}:{cellphone}", $"{country.PhoneCode}{cellphone}"); }
public void FiiiPOSSendSecurityValidateCellphoneCode(Guid merchantId, string code) { MerchantAccount merchant = new MerchantAccountDAC().GetById(merchantId); if (merchant == null) { throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, Resources.用户不存在); } string fullCellphone = $"{merchant.PhoneCode}{merchant.Cellphone}"; SecurityVerify.SendCode(new MandatoryCellphoneVerifier(), SystemPlatform.FiiiPOS, code + merchant.Id.ToString(), fullCellphone); }
/// <summary> /// 发送验证原邮箱的验证码 /// </summary> /// <param name="accountId"></param> /// <param name="emailAddress"></param> public void SendUpdateOriginalEmailCode(Guid accountId, string emailAddress) { var dac = new MerchantAccountDAC(); var account = dac.GetById(accountId); if (account.Email != emailAddress) { throw new CommonException(ReasonCode.EMAIL_NOT_MATCH, Resources.原邮箱地址不正确); } string subject = Resources.验证码邮箱标题; SecurityVerify.SendCode(new UpdateEmailOriginalVerifier(), SystemPlatform.FiiiPOS, accountId.ToString(), emailAddress, subject); }
public void SendSetEmailCode(UserAccount user, string email) { if (!string.IsNullOrEmpty(user.Email)) { throw new ApplicationException(MessageResources.EmailAlredaySet); } if (new UserAccountDAC().GetByEmail(email) != null) { throw new ApplicationException(MessageResources.EmailHasBind); } string subject = Resources.VerificationCodoEmailTitle; SecurityVerify.SendCode(new SetEmailVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), email, subject); }
/// <summary> /// 发送验证原邮箱的验证码 /// </summary> /// <param name="email"></param> public void SendUpdateOriginalEmailCode(UserAccount user, string email) { if (string.IsNullOrEmpty(user.Email)) { throw new ApplicationException(MessageResources.NotBindMail); } if (user.Email != email) {//必须要相等 throw new CommonException(ReasonCode.EMAIL_NOT_MATCH, MessageResources.IncorrectOriginalEmailAddress); } string subject = Resources.VerificationCodoEmailTitle; SecurityVerify.SendCode(new UpdateEmailOriginalVerifier(), SystemPlatform.FiiiPay, user.Id.ToString(), email, subject); }
/// <summary> /// 发送登录验证码 /// </summary> /// <param name="phoneCode"></param> /// <param name="cellphone"></param> public bool SendLoginCode(string phoneCode, string cellphone) { var user = new UserAccountDAC().GetByFullPhoneCode(phoneCode, cellphone); if (user == null) { throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, Properties.Resource.MsgAccountNotExist); } if (user.Status == 0) { throw new CommonException(ReasonCode.ACCOUNT_DISABLED, Properties.Resource.MsgAccountDisabled); } SecurityVerify.SendCode(new LoginCellphoneVerifier(), SystemPlatform.FiiiShop, $"{user.CountryId}:{cellphone}", $"{phoneCode}{cellphone}"); return(true); }
/// <summary> /// 发送忘记密码验证码 /// </summary> /// <param name="countryId"></param> /// <param name="cellphone"></param> public void SendForgotPasswordCode(int countryId, string cellphone) { var user = new UserAccountDAC().GetByCountryIdAndCellphone(countryId, cellphone); if (user == null) { throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, MessageResources.AccountNotFound); } if (user.Status == 0) { throw new CommonException(ReasonCode.ACCOUNT_DISABLED, MessageResources.AccountDisabled); } var country = new CountryComponent().GetById(countryId); SecurityVerify.SendCode(new ForgetPasswordCellphoneVerifier(), SystemPlatform.FiiiPay, $"{countryId}:{cellphone}", $"{country.PhoneCode}{cellphone}"); }
public void SendBindingSMS(string cellphone, int countryId, string merchantAccount, string sn) { var pos = new POSDAC().GetBySn(sn); if (pos == null) { throw new CommonException(ReasonCode.POSSN_ERROR, Resources.SN码不存在); } var account = new MerchantAccountDAC().GetByUsername(merchantAccount); if (account == null) { throw new GeneralException(Resources.AccountNotExists); } if (account.POSId.HasValue) { if (account.POSId == pos.Id) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.AccountHasBoundThisPOS); } else { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.AccountHasBoundOtherPOS); } } var country = new CountryComponent().GetById(countryId); if (country == null) { throw new CommonException(10000, Resources.国家不存在); } if (account.PhoneCode != country.PhoneCode || account.Cellphone != cellphone) { throw new GeneralException(Resources.当前手机号与账号绑定的手机号不一致); } SecurityVerify.SendCode(new BindAccountCellphoneVerifier(), SystemPlatform.FiiiPOS, merchantAccount, $"{account.PhoneCode}{account.Cellphone}"); }
public void SendSetEmailCode(Guid accountId, string email) { var account = new MerchantAccountDAC().GetById(accountId); if (!string.IsNullOrEmpty(account.Email)) { throw new ApplicationException(); } if (new MerchantAccountDAC().GetByEmail(email) != null) { throw new CommonException(ReasonCode.EMAIL_BINDBYOTHER, Resources.此邮箱已经绑定到其他邮箱); } string subject = Resources.验证码邮箱标题; SecurityVerify.SendCode(new SetEmailVerifier(), SystemPlatform.FiiiPOS, accountId.ToString(), email, subject); var model = new FiiiPosSetEmailVerify { Email = email }; SecurityVerify.SetModel(new CustomVerifier("SetEmail"), SystemPlatform.FiiiPOS, account.Id.ToString(), model); }
public void SendSecurityValidateCellphoneCode(UserAccount user, string code) { var country = new CountryComponent().GetById(user.CountryId); SecurityVerify.SendCode(new MandatoryCellphoneVerifier(), SystemPlatform.FiiiPay, code + user.Id, $"{country.PhoneCode}{user.Cellphone}"); }