Пример #1
0
        public async Task <ActionResult <ApplicationUserViewModel> > ConfirmEmail([FromQuery] string token,
                                                                                  [FromQuery] string email)
        {
            ApplicationUser user = await _userRepository.FindByNameOrEmailAsync(email);

            if (user is null)
            {
                return(NotFound($"El usuario/email {email} no se encuentra registrado."));
            }

            user = await _userRepository.ConfirmEmailAsync(user, token.Base64ForUrlDecode());

            return(_mapper.Map <ApplicationUserViewModel>(user));
        }
Пример #2
0
        public async Task Generate_ConfirmEmailToken_And_ConfirmEmail()
        {
            ApplicationUser applicationUser = await _applicationUserRepository.FindByNameOrEmailAsync("admin");

            Assert.IsNotNull(applicationUser);

            string confirmationToken =
                await _applicationUserRepository.GenerateEmailConfirmationTokenAsync(applicationUser);

            Assert.IsNotNull(confirmationToken);

            ApplicationUser result =
                await _applicationUserRepository.ConfirmEmailAsync(applicationUser, confirmationToken);

            Assert.IsNotNull(result);
            Assert.IsTrue(applicationUser.EmailConfirmed);
        }
Пример #3
0
        public async Task <IActionResult> ConfirmEmailAsync(string email, string code)
        {
            try
            {
                var result = await _aApplicationUserRepository.ConfirmEmailAsync(email, code);

                if (result)
                {
                    return(OKResult(1, "Email confirmed"));
                }

                return(OKResult(0, "Link expired."));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }