示例#1
0
        /// <summary>
        /// 生成验证码
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<UserValidateCodeOutput> GenderValidateCode(UserValidateCodeInput input)
        {
            string vCode = await this.InnerGenderValidateCode(input.NameOrEmail, input.SessionId, input.HostUrl, DateTime.Now);

            return new UserValidateCodeOutput
            {
                ValidateCode = vCode
            };
        }
示例#2
0
        /// <summary>
        /// 校验验证码是否正确
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<bool> CheckValidateCode(UserValidateCodeInput input)
        {
            bool result = await Task.Run(async () =>
           {
               bool checkResult = false;
               var dateTime = DateTime.Now;
               for (int i = 0; i < 5; i++)
               {
                   string vCode = await this.InnerGenderValidateCode(input.NameOrEmail, input.SessionId, input.HostUrl, dateTime);
                   if (vCode.ToLower() == input.VCode.ToLower())
                   {
                        //校验通过
                        checkResult = true;
                       break;
                   }
                   dateTime = dateTime.AddMinutes(-1);
               }
               return checkResult;
           });

            return result;
        }