コード例 #1
0
        public async Task <IActionResult> Register([FromBody] RegisterRequestModel model)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(Forbid());
            }

            if (!await _captchaService.TryVerifyCaptchaAsync(model.RecaptchaToken))
            {
                return(this.BadRequestError("Invalid captcha."));
            }

            var registerResult = await _identityService.CreateUserAsync(model);

            if (registerResult == IdentityResult.Success)
            {
                return(Ok());
            }

            return(BadRequest(registerResult.Errors.ToStringEnumerable()));
        }