コード例 #1
0
        public async Task <IActionResult> Register([FromBody] RegisterRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (model.Password != model.ConfirmPassword)
            {
                return(BadRequest());
            }

            int openUserNumber = await _userManager.GetOpenDisplayNumber(model.DisplayName);

            var user   = new FantasyCriticUser(Guid.NewGuid(), model.DisplayName, openUserNumber, model.EmailAddress, model.EmailAddress, false, "", "", _clock.GetCurrentInstant());
            var result = await _userManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                return(BadRequest(result.Errors));
            }

            _logger.LogInformation("User created a new account with password.");

            var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

            string baseURL = $"{Request.Scheme}://{Request.Host.Value}";
            await _emailSender.SendConfirmationEmail(user, code, baseURL);

            return(Created("", user.UserID.ToString()));
        }
コード例 #2
0
        public async Task <IActionResult> ResendConfirmationEmail([FromBody] AdminResendConfirmationEmail request)
        {
            var user = await _userManager.FindByIdAsync(request.UserID.ToString());

            if (user is null)
            {
                return(BadRequest());
            }

            var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

            string baseURL = $"{Request.Scheme}://{Request.Host.Value}";
            await _emailSender.SendConfirmationEmail(user, code, baseURL);

            return(Ok());
        }