Academatica.Api/Academatica.Api.Users/Controllers/UsersController.cs
/// <summary>
/// Endpoint used to send an email change confirmation code to the user's email address.
/// </summary>
/// <param name="id">User ID.</param>
Endpoint used to send an email change confirmation code to the user's email address.
Endpoint used to send an email change confirmation code to the user ' s email address .
[HttpPost]
        [Route("{id}/email/confirmation-code")]
        public async Task<IActionResult> SendUserEmailConfirmationCode(Guid id)
        {
            var userId = User.FindFirst("sub")?.Value;
            if (userId != id.ToString())
            {
                return Forbid();
            }
            var user = _academaticaDbContext.Users.Where(x => x.Id == id).FirstOrDefault();
            if (user == null)
            {
                return NotFound("Invalid user ID.");
            }
            var code = await _confirmationCodeManager.CreateEmailConfirmationCode(user.Id);
            await _userEmailService.SendConfirmationCode(user, code, NotificationType.EmailChangeNotification);
            return Ok();
        }
[ HttpPost ] [ Route ( " " ) ] public async Task < IActionResult > SendUserEmailConfirmationCode ( Guid id ) { var userId = User . FindFirst ( " " ) ? . Value ; if ( userId != id . ToString ( ) ) { return Forbid ( ) ; } var user = _academaticaDbContext . Users . Where ( x => x . Id == id ) . FirstOrDefault ( ) ; if ( user == null ) { return NotFound ( " " ) ; } var code = await _confirmationCodeManager . CreateEmailConfirmationCode ( user . Id ) ; await _userEmailService . SendConfirmationCode ( user , code , NotificationType . EmailChangeNotification ) ; return Ok ( ) ; }
Endpoint used to send an email change confirmation code to the user's email address.
Endpoint used to send an email change confirmation code to the user ' s email address .
id
Guid
None