Beispiel #1
0
        public async Task <ApiResult> Handle(ChangeEmail request, CancellationToken cancellationToken)
        {
            var user = await _userManager.GetUserAsync(request.User);

            if (user == null)
            {
                return(new ApiResult {
                    Success = false
                });
                // return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }

            var email = await _userManager.GetEmailAsync(user);

            if (request.Email != email)
            {
                await _emailConfirmationService.SendConfirmEmailChangeMessage(user, request.Email, cancellationToken);

                // StatusMessage = "Confirmation link to change email sent. Please check your email.";
                return(new ApiResult());
            }

            // StatusMessage = "Your email is unchanged.";
            return(new ApiResult());
        }