Example #1
0
        public async Task <ServiceResponse> ResendConfirmationEmailAsync(ResendConfirmationEmailRequest request)
        {
            var user = await UserManager.FindByEmailAsync(request.Email);

            if (user == null)
            {
                ErrorResultToReturn = new ErrorResult(Errors.AccountErrors.CouldNotFindUserWithGivenEmail.SetParams(request.Email));
                throw new RestException(HttpStatusCode.BadRequest, ErrorResultToReturn);
            }

            if (user.IsDeleted)
            {
                ErrorResultToReturn = new ErrorResult(Errors.AccountErrors.DeletedAccountCanNotBeConfirmed);
                throw new RestException(HttpStatusCode.BadRequest, ErrorResultToReturn);
            }

            if (user.EmailConfirmed)
            {
                ErrorResultToReturn = new ErrorResult(Errors.AccountErrors.EmailIsAlreadyConfirmed.SetParams(request.Email));
                throw new RestException(HttpStatusCode.BadRequest, ErrorResultToReturn);
            }

            var generatedEmailConfirmationToken = await UserManager.GenerateEmailConfirmationTokenAsync(user);

            var sendEmailResponse = await _emailService.SendEmailAfterRegistrationAsync(user, generatedEmailConfirmationToken,
                                                                                        request.UrlToIncludeInEmail, request.Language);

            if (sendEmailResponse.ResponseType == HttpStatusCode.OK)
            {
                return(new ServiceResponse(HttpStatusCode.OK));
            }

            ErrorResultToReturn = new ErrorResult(Errors.EmailErrors.ErrorOccuredWhileSendingEmailWithConfirmationLink.SetParams(request.Email));
            throw new RestException(HttpStatusCode.BadRequest, ErrorResultToReturn);
        }
Example #2
0
        public async Task <IActionResult> ResendConfirmationEmail([FromBody] ResendConfirmationEmailRequest request)
        {
            var response = await _accountService.ResendConfirmationEmailAsync(request);

            return(SendResponse(response));
        }
Example #3
0
        public async Task <IActionResult> ResendConfirmationEmail([FromBody] ResendConfirmationEmailRequest request)
        {
            OperationResult result = await accountService.ResendConfirmationEmail(request.Email, request.Password);

            return(ToActionResult(result));
        }