/// <summary>
        /// 登录-使用Email验证码
        /// </summary>
        /// <param name="emailInfo"></param>
        /// <returns></returns>
        public async Task <dynamic> LoginByEmailVerifyCode(DTOAPI_EmailVerifyCode emailInfo)
        {
            Account account = this.accesser.Get(email: emailInfo.email).Item1;

            if (account == null)
            {
                return(new DTOAPIRes_Login
                {
                    accessToken = "",
                    state = 3,
                    msg = "用户不存在"
                });
            }

            string key_captcha = $"LoginCaptcha_{emailInfo.email}";

            if (!this.captchaHelper.IsValidCaptcha($"LoginCaptcha_{emailInfo.email}", emailInfo.verifyCode))
            {
                return(new DTOAPIRes_Login
                {
                    accessToken = "",
                    state = 4,
                    msg = "验证码错误"
                });
            }

            await this.publishEndpoint.Publish(new DeleteAccountCaptchaCommand
            {
                key = key_captcha
            });

            return(this.GenLoginData(account, account.Password));
        }
Esempio n. 2
0
        public async Task <IActionResult> LoginByEmailVerifyCode([FromBody] DTOAPI_EmailVerifyCode emailInfo)
        {
            try
            {
                var loginInfo = await this.services.LoginByEmailVerifyCode(emailInfo).ConfigureAwait(false);

                return(OkEx(loginInfo));
            }
            catch (Exception ex)
            {
                return(JsonToCamelCase(ex.Message, 50000, 50000));
            }
        }
        public async Task <IActionResult> SendForgotPwdVerifyCodeByEmail([FromBody] DTOAPI_EmailVerifyCode emailInfo)
        {
            try
            {
                await this.services.SendForgotPwdVerifyCodeByEmail(emailInfo).ConfigureAwait(false);

                return(OkEx(""));
            }
            catch (Exception ex)
            {
                return(JsonToCamelCase(ex.Message, 50000, 50000, ex.Message));
            }
        }
Esempio n. 4
0
        public async Task <IActionResult> IsValidEmailCodeByRegister([FromBody] DTOAPI_EmailVerifyCode emailInfo)
        {
            try
            {
                bool bSuccess = await this.services.IsValidEmailCodeByRegister(emailInfo).ConfigureAwait(false);

                return(OkEx(new { success = bSuccess }));
            }
            catch (Exception ex)
            {
                return(this.JsonToCamelCase(ex.Message, 50000, 50000, ex.Message));
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="emailInfo"></param>
        /// <returns></returns>
        public async Task <bool> IsValidEmailCodeByRegister(DTOAPI_EmailVerifyCode emailInfo)
        {
            bool bSuccess = false;

            if (!EmailHepler.IsValid(emailInfo.email))
            {
                throw new Exception("邮箱格式不正确");
            }


            bSuccess = this.captchaHelper.IsValidCaptcha($"RegisterCaptcha_{emailInfo.email.ToLower()}", emailInfo.verifyCode);

            return(bSuccess);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="emailInfo"></param>
        /// <returns></returns>
        public async Task SendLoginVerifyCodeByEmail(DTOAPI_EmailVerifyCode emailInfo)
        {
            if (!EmailHepler.IsValid(emailInfo.email))
            {
                throw new Exception("邮箱格式不正确");
            }
            var account = this.accesser.Get(email: emailInfo.email).Item1;

            if (account == null)
            {
                throw new Exception("用户不存在");
            }

            await this.publishEndpoint.Publish(new SendLoginEmailCapthcaCommand
            {
                key   = $"LoginCaptcha_{emailInfo.email.ToLower()}",
                email = emailInfo.email
            });
        }