public async Task <byte[]> GetGraphicCaptchaAsync()
        {
            var strs = GraphicCaptchaManager.GetRandomCaptchString(6);

            cacheManager.Set($"Captcha:Graphic", string.Join("", strs));
            return(await Task.FromResult(GraphicCaptchaManager.GetBytes(strs)));
        }
Пример #2
0
        //    public async Task ValidateMessageCaptchaAsync(ValidateMessageCaptchaAsyncRequest input)
        //    {
        //        await captchaManager.MessageCaptchaValidateAsync(input.CaptchaType, input.Mobile, input.Captcha);
        //    }

        //    public async Task LocalRegistrationAsync(LocalRegistrationAsyncRequest input)
        //    {
        //        await userAccountManager.LocalRegistrationAsync(input.Mobile, input.Password);
        //    }

        //    public async Task ValidateGraphicCaptchaAndSendMessageCaptchaAsync(ValidateGraphicCaptchaAndSendMessageCaptchaAsyncRequest input)
        //    {
        //        // try find user by mobile
        //        var user = await userAccountManager.FindAsync(input.Mobile);

        //        switch (input.CaptchaType)
        //        {
        //            case MESSAGE_CAPTCHA_TYPE.REGISTER:

        //                // validate user mobile is exsit
        //                if (user != null)
        //                {
        //                    throw new UserFriendlyException(VALIDATE_GRAPHIC_CAPTCHA_AND_SEND_MESSAGE_CAPTCHA_RETURN_CODE.MOBILE_ALREADY_EXISTS);
        //                }

        //                // validate register graphic captcha
        //                await captchaManager.GraphicCaptchaValidateAsync("",input.GraphicCaptcha);

        //                // send register message captcha and it valid 10 minutes
        //                await captchaManager.MessageCaptchaSendAsync(MESSAGE_CAPTCHA_TYPE.REGISTER, input.Mobile, 10);

        //                break;

        //            case MESSAGE_CAPTCHA_TYPE.RETRIEVE_PASSWORD:

        //                // validate user mobile is exsit

        //                if (user == null)
        //                {
        //                    throw new UserFriendlyException(VALIDATE_GRAPHIC_CAPTCHA_AND_SEND_MESSAGE_CAPTCHA_RETURN_CODE.MOBILE_NOT_EXISTS);
        //                }
        //                // validate retrieve password graphic captcha
        //                await captchaManager.GraphicCaptchaValidateAsync("", input.GraphicCaptcha);

        //                // send retrieve password message captcha
        //                await captchaManager.MessageCaptchaSendAsync(MESSAGE_CAPTCHA_TYPE.RETRIEVE_PASSWORD, input.Mobile, 10);
        //                break;

        //            default:
        //                break;
        //        }
        //    }

        //    public async Task RetrievePasswordAsync(RetrievePasswordAsyncRequest input)
        //    {
        //        // try find user by mobile
        //        var user = await userAccountManager.FindAsync(input.Mobile);
        //    }

        public Task <byte[]> GetGraphicCaptchaAsync(MESSAGE_CAPTCHA_TYPE type)
        {
            switch (type)
            {
            case MESSAGE_CAPTCHA_TYPE.REGISTER:

                // register graphic captcha
                return(Task.FromResult(GraphicCaptchaManager.GetBytes()));

            case MESSAGE_CAPTCHA_TYPE.RETRIEVE_PASSWORD:

                // reset password graphic captcha
                return(Task.FromResult(GraphicCaptchaManager.GetBytes()));

            default:
                break;
            }

            throw new UserFriendlyException(GETGRAPHIC_CAPTCHA_ASYNC_RETURN_CODE.INVALID_GRAPHIC_CAPTCHA);
        }
Пример #3
0
 public Task <byte[]> GraphicCaptchaGenderatorAsync()
 {
     // build and return a graphic captcha bytes
     return(Task.FromResult(GraphicCaptchaManager.GetBytes()));
 }