Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
991 B
2
Indexable
Never
     [HttpPost("Verify-Email")]
     public async Task<IActionResult> VerifyEmail(VerificationDto verificationDto)
     {
         var user = await _userManager.FindByEmailAsync(verificationDto.Email);

         if (user != null)
         {
             if (!string.IsNullOrEmpty(user.VerificationCode) && user.VerificationCode == verificationDto.VerificationCode)
             {
                 user.EmailConfirmed = true;
                 user.VerificationCode = string.Empty; 
                 await _userManager.UpdateAsync(user);
                 return Ok("Email Verified");
             }
             else if (user.EmailConfirmed)
             {
                 return BadRequest("Ha Ha Ha User is already verified");
             }
             else
             {
                 return BadRequest("Invalid verification code");
             }
         }
         else
         {
             return BadRequest("User does not exist");
         }
     }
Leave a Comment