Exemplo n.º 1
0
        public async Task ConfirmEmail(string email, string encodedToken)
        {
            var user = await _userManager.FindByEmailAsync(email);

            if (user != null)
            {
                var decodedToken   = _encodingService.GetWebDecodedString(encodedToken);
                var identityResult = await _userManager.ConfirmEmailAsync(user, decodedToken);

                if (!identityResult.Succeeded)
                {
                    throw new InvalidOperationException($"Could not confirm {email} because the token was incorrect.");
                }
            }
            else
            {
                throw new InvalidOperationException($"Could not confirm {email} because it is not registered.");
            }
        }