AngularAzureSearch.WebAPI.Controllers.AccountController.ConfirmEmail C# (CSharp) Method

ConfirmEmail() private method

private ConfirmEmail ( string userId, string code ) : Task
userId string
code string
return Task
        public async Task<IHttpActionResult> ConfirmEmail(string userId, string code)
        {
            if (userId == null || code == null)
            {
                return BadRequest("UserId and/or Code is missing.");
            }
            try
            {
                // UrlDecode the token
                code = HttpUtility.UrlDecode(code);

                // IMPORTANT STEP!!! The UrlDecode removes all '+' from the 
                // originally generated token and replaces it with spaces ' '.
                // We have to put the + signs back.
                code = code.Replace(' ', '+');

                // Now confirm the email and it should work!
                var result = await UserManager.ConfirmEmailAsync(userId, code);
                if (result.Succeeded)
                {
                    return Ok();
                }
                else
                {
                    return GetErrorResult(result);
                }

            }
            catch (Exception)
            {

                throw;
            }
        }