Пример #1
0
        public async Task<IActionResult> ConfirmEmail(string id, string code)
        {
            if(!ModelState.IsValid)
            {
                return View();
            }

            Result result = await _emailConfirmationService.ConfirmEmail(id, code);
            if(result.Failure)
            {
                ModelState.AddErrors(result.Errors);
                return View();
            }

            return View();
        }
Пример #2
0
        public async Task <OperationResult> ConfirmEmail(string userId, string token)
        {
            User user = await userManager.FindByIdAsync(userId);

            if (user == null)
            {
                return(OperationResult.Invalid(
                           new OperationError($"User with id {userId} not found", OperationError.ErrorType.NotFound)));
            }

            if (user.EmailConfirmed)
            {
                return(OperationResult.Invalid($"User with id {userId} already has a confirmed e-mail"));
            }

            OperationResult result = await emailConfirmationService.ConfirmEmail(user, token);

            return(result);
        }