public async Task <IActionResult> ResetPassword(ResetPasswordRequestModel model)
        {
            await _loggingService.SaveAuditLog($"Retrieving user with email {model.Email}", AuditActionEnum.Read);

            var user = await _userRepository.GetUserByEmail(model.Email);

            if (user == null)
            {
                return(BadRequest());
            }

            var token = TokenHelper.GenerateResetPasswordToken();

            var resetPasswordToken = new ResetPasswordToken
            {
                Token          = token,
                ExpirationDate = DateTime.Now.AddMinutes(30),
                UserId         = user.UserId
            };

            await _loggingService.SaveAuditLog($"Creating reset-password token for user with user id {user.UserId}",
                                               AuditActionEnum.Create);

            await _authenticationRepository.CreateToken(resetPasswordToken);

            await _emailService.SendEmail(new EmailData(token, model.Email, EmailTypeEnum.PasswordRecovery));

            return(Ok());
        }
        public async Task <AuthenticationTokens> GenerateTokens(int userId)
        {
            var tokenHandler = new JwtSecurityTokenHandler();
            var accessToken  = tokenHandler.CreateToken(SetUpToken(userId));
            var refreshToken = RefreshTokenHelper.Generate(userId);

            await _authenticationRepository.CreateToken(refreshToken);

            var authenticationTokens = new AuthenticationTokens
            {
                AccessToken  = tokenHandler.WriteToken(accessToken),
                RefreshToken = refreshToken.Token
            };

            return(authenticationTokens);
        }