Academatica.Api/Academatica.Api.Users/Controllers/UsersController.cs
/// <summary>
/// Endpoint used to roll the email address change back.
/// </summary>
/// <param name="id">User ID.</param>
/// <param name="code">Email change code (generated automatically).</param>
/// <param name="oldEmail">Previous email.</param>
Endpoint used to roll the email address change back.
Endpoint used to roll the email address change back .
[AllowAnonymous]
        [HttpGet]
        [Route("{id}/email/rollback")]
        public async Task<IActionResult> RollbackUserEmailChange(Guid id, string code, string oldEmail)
        {
            var website = _configuration["Website"];
            if (code == null)
            {
                return Redirect(website + "/error");
            }
            var user = await _userManager.FindByIdAsync(id.ToString());
            if (user == null)
            {
                return Redirect(website + "/error");
            }
            var result = await _userManager.ChangeEmailAsync(user, oldEmail, code);
            if (result.Succeeded)
            {
                return Redirect(website + "/email-reverted");
            }
            return Redirect(website + "/error");
        }
[ AllowAnonymous ] [ HttpGet ] [ Route ( " " ) ] public async Task < IActionResult > RollbackUserEmailChange ( Guid id , string code , string oldEmail ) { var website = _configuration [ " " ] ; if ( code == null ) { return Redirect ( website + " " ) ; } var user = await _userManager . FindByIdAsync ( id . ToString ( ) ) ; if ( user == null ) { return Redirect ( website + " " ) ; } var result = await _userManager . ChangeEmailAsync ( user , oldEmail , code ) ; if ( result . Succeeded ) { return Redirect ( website + " " ) ; } return Redirect ( website + " " ) ; }
Endpoint used to roll the email address change back.
Endpoint used to roll the email address change back .
id
Guid
None
code
string
Email change code (generated automatically).
Email change code ( generated automatically ) .
oldEmail
string
None