Esempio n. 1
0
        /// <summary>
        /// 获取用户注册验证码
        /// </summary>
        /// <param name="phoneNo">手机号</param>
        /// <param name="codeType"></param>
        /// <returns>业务操作结果</returns>
        public async Task<OperationResult> GetSmsValidateCode(string phoneNo, CodeType codeType)
        {
            string validateCode = new ValidateCoder().GetCode(6, ValidateCodeType.Number);
            var codeEntity = new ValidateCode()
            {
                PhoneNo = phoneNo,
                Code = validateCode,
                CodeType = codeType
            };
            await ValidateCodeRepo.InsertAsync(codeEntity);

            //发送手机短信
            var smsContent = "您本次的验证码为" + validateCode + ",工作人员不会向您索要此验证码,请勿向任何人泄露。[右行养车]";
            Sms.Send(phoneNo,1, smsContent);


            return new OperationResult(OperationResultType.Success, "验证码发送成功", validateCode);
        }
Esempio n. 2
0
        /// <summary>
        /// 发送验证码
        /// </summary>
        /// <param name="codeKey">验证码Key</param>
        /// <param name="validateType">验证方式</param>
        /// <param name="codeType">验证码类型</param>
        /// <param name="sendAction">发送委托</param>
        /// <returns>业务操作结果</returns>
        private async Task<OperationResult> SendValidateCode(string codeKey, ValidateType validateType, CodeType codeType, Action<string> sendAction)
        {
            codeKey.CheckNotNull("codeKey");
            sendAction.CheckNotNull("sendAction");

            string validateCode = new ValidateCoder().GetCode(6, ValidateCodeType.Number);
            var codeEntity = new ValidateCode()
            {
                CodeKey = codeKey,
                Code = validateCode,
                ValidateType = validateType,
                CodeType = codeType
            };
            await ValidateCodeRepo.InsertAsync(codeEntity);

            sendAction(validateCode);
            return new OperationResult(OperationResultType.Success, "验证码发送成功", "");
        }