예제 #1
0
        public async Task Search_User_By_UserName_Or_Email()
        {
            ApplicationUser applicationUser =
                await _applicationUserRepository.FindByNameOrEmailAsync("*****@*****.**");

            Assert.IsNotNull(applicationUser);
            Assert.AreEqual("*****@*****.**", applicationUser.Email);
        }
예제 #2
0
        public async Task <ActionResult <ApplicationUserViewModel> > ResetPassword(string usernameOrEmail,
                                                                                   [FromBody] ResetPasswordModel resetPasswordModel)
        {
            ApplicationUser user = await _userRepository.FindByNameOrEmailAsync(usernameOrEmail);

            if (user is null)
            {
                return(BadRequest(
                           $"No existe un usuario identificado con el nombre de usuario o email {usernameOrEmail}."));
            }

            IdentityResult resetPasswordResult = await _userRepository.ResetPasswordAsync(user,
                                                                                          resetPasswordModel.Token.Base64ForUrlDecode(), resetPasswordModel.NewPassword);

            if (!resetPasswordResult.Succeeded)
            {
                return(this.IdentityResultErrors(resetPasswordResult));
            }

            return(_mapper.Map <ApplicationUserViewModel>(user));
        }