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); }
/// <summary> /// 发送原邮箱验证码 20180523 /// </summary> /// <param name="accountId"></param> /// <param name="emailAddress"></param> public async Task SendVerifyOriginalEmail(Guid accountId, string emailAddress) { var dac = new MerchantAccountDAC(); var account = dac.GetById(accountId); var accountByEmail = dac.GetByEmail(emailAddress); if (accountByEmail != null && accountByEmail.Id != accountId) { throw new CommonException(ReasonCode.FiiiPosReasonCode.EMAIL_BINDED, "该邮箱已绑定到其他账户"); } string key = $"{RedisKeys.FiiiPOS_WEB_EmailVerification}:{accountId}"; string code = RandomAlphaNumericGenerator.GenerateAllNumber(6); Dictionary <string, string> dic = new Dictionary <string, string> { { "AccountId", accountId.ToString() }, { "EmailAddress", emailAddress }, { "Code", code } }; RedisHelper.Set(key, dic, new TimeSpan(0, Constant.EMAIL_EXPIRED_TIME, 0)); string subject = Resources.验证码邮箱标题; string content = string.Format(Resources.验证码邮箱模版, code, Constant.EMAIL_EXPIRED_TIME); EmailAgent agent = new EmailAgent(); await agent.SendAsync(emailAddress, subject, content, 5); }