예제 #1
0
        public async Task <IActionResult> Verify(EmailTokenDto dto)
        {
            if (string.IsNullOrWhiteSpace(dto.Email) || string.IsNullOrWhiteSpace(dto.VerificationToken))
            {
                return(BadRequest(new BadRequestError("Email and a verification token have to be set to verify an email address")));
            }

            try
            {
                return(Ok(await _userService.VerifyEmailAsync(dto.Email, dto.VerificationToken)));
            }
            catch (IdentityUserServiceException exception)
            {
                return(BadRequest(new BadRequestError(exception.ToString())));
            }
        }
예제 #2
0
        public async Task <IActionResult> VerifyMailChange(EmailTokenDto dto)
        {
            if (dto == null || string.IsNullOrWhiteSpace(dto.Email) || string.IsNullOrWhiteSpace(dto.VerificationToken))
            {
                return(BadRequest(new BadRequestError("Email and verification token have to be set to verify mail change")));
            }

            try
            {
                var result = await _userService.UpdateEmailAsync(User, dto.Email, dto.VerificationToken);

                if (result == null)
                {
                    return(BadRequest());
                }

                return(Ok(result));
            }
            catch (IdentityUserServiceException exception)
            {
                return(BadRequest(new BadRequestError(exception.ToString())));
            }
        }