Example #1
0
        public async Task ResetSenha(ResetSenhaUsuarioViewModel resetSenha)
        {
            Token _token = _repositoryToken.GetById(resetSenha.TokenId);

            if (_token == null)
            {
                throw new ApiException(ApiErrorCodes.INVTOK);
            }

            await ValidatePassword(resetSenha.NovaSenha, resetSenha.ConfirmacaoNovaSenha, _token.Autenticacao);

            IdentityResult _resetSenhaResult = await _userManager.ResetPasswordAsync(_token.Autenticacao, _token.Value, resetSenha.NovaSenha);

            if (!_resetSenhaResult.Succeeded)
            {
                throw new ApiException(ApiErrorCodes.INVTOK);
            }

            _token.Autenticacao.SetUnexpirablePassword();

            if (!_uow.Commit())
            {
                throw new ApiException(ApiErrorCodes.ERALTSEIDNT);
            }
        }
Example #2
0
        public async Task <IActionResult> ResetSenha(ResetSenhaUsuarioViewModel resetSenha)
        {
            await _service.ResetSenha(resetSenha);

            return(Ok());
        }