Academatica.Api/Academatica.Api.Users/Controllers/UsersController.cs
/// <summary>
/// Endpoint used to check if specified code is equal to a password change confirmation code sent to user's email address.
/// </summary>
/// <param name="id">User ID.</param>
/// <param name="code">Code to check.</param>
Endpoint used to check if specified code is equal to a password change confirmation code sent to user's email address.
Endpoint used to check if specified code is equal to a password change confirmation code sent to user ' s email address .
[HttpGet]
        [Route("{id}/password/confirmation-code")]
        public async Task<IActionResult> CheckUserPasswordConfirmationCode(Guid id, [FromQuery] string code)
        {
            var userId = User.FindFirst("sub")?.Value;
            if (userId != id.ToString())
            {
                return Forbid();
            }
            var user = _academaticaDbContext.Users.Where(x => x.Id == id).First();
            if (user == null)
            {
                return NotFound("Invalid user ID.");
            }
            if (code == null)
            {
                return BadRequest("No confirmation code specified.");
            }
            var cachedCode = await _confirmationCodeManager.GetPasswordConfirmationCode(user.Id);
            if (cachedCode == code)
            {
                return Ok(new CheckUserPasswordConfirmationCodeResponseDto
                {
                    Success = true
                });
            }
            else
            {
                return Ok(new CheckUserPasswordConfirmationCodeResponseDto
                {
                    Success = false
                });
            }
        }
[ HttpGet ] [ Route ( " " ) ] public async Task < IActionResult > CheckUserPasswordConfirmationCode ( Guid id , [ FromQuery ] string code ) { var userId = User . FindFirst ( " " ) ? . Value ; if ( userId != id . ToString ( ) ) { return Forbid ( ) ; } var user = _academaticaDbContext . Users . Where ( x => x . Id == id ) . First ( ) ; if ( user == null ) { return NotFound ( " " ) ; } if ( code == null ) { return BadRequest ( " " ) ; } var cachedCode = await _confirmationCodeManager . GetPasswordConfirmationCode ( user . Id ) ; if ( cachedCode == code ) { return Ok ( new CheckUserPasswordConfirmationCodeResponseDto { Success = true } ) ; } else { return Ok ( new CheckUserPasswordConfirmationCodeResponseDto { Success = false } ) ; } }
Endpoint used to check if specified code is equal to a password change confirmation code sent to user's email address.
Endpoint used to check if specified code is equal to a password change confirmation code sent to user ' s email address .
id
Guid
None
string
[FromQuery]
code
Code to check.
Code to check .