コード例 #1
0
        public async Task <IActionResult> OnPostSendConfAsync()
        {
            var userId = User.FindFirst(JwtClaimTypes.Subject)?.Value;
            var user   = await _userManager.FindByIdAsync(userId);

            if (user != null)
            {
                var res = await _acctEmailService.SendConfToAuthUserAsync(user);

                res.Match(
                    e => ModelState.AddModelError("", e),
                    () => SuccessMessage = $"A confirmation link has been sent to {Input.NewEmail}. You may need to check your spam folder."
                    );
                SetPrepopulatedFormData(user);
                return(Page());
            }
            _logger.LogEmptyAuthenticatedUser(user);
            return(RedirectToPage("error"));
        }
コード例 #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            var newUser = new User(Input.FirstName, Input.LastName, Input.Email);
            var res     = await _userManager.CreateAsync(newUser, Input.Password);

            if (res.Errors.Count() > 0)
            {
                this.AddIdentityResultErrors(res);
                return(Page());
            }
            // Send email confirmation email
            await _acctEmailService.SendConfToAuthUserAsync(newUser);

            return(RedirectToPage("Login"));
        }