Пример #1
0
        public async Task ValidateResetTokenAsync(ValidateResetTokenRequestDTO model)
        {
            var account = await this._repository.GetByAsync((e => e.ResetToken == model.Token && e.ResetTokenExpires > DateTime.UtcNow));

            if (account == null)
            {
                throw new ApplicationException("Invalid token");
            }

            if (!account.Active)
            {
                throw new ApplicationException("Conta desativada!");
            }
        }
 public ActionResult ValidateResetToken(ValidateResetTokenRequestDTO model)
 {
     try
     {
         if (_userService.ValidateResetToken(model))
         {
             return(Ok(new { message = "Token is valid" }));
         }
     }
     catch (AppException ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
     return(BadRequest(new { message = "Invalid token" }));
 }
Пример #3
0
        public bool ValidateResetToken(ValidateResetTokenRequestDTO model)
        {
            var user = _userData.GetByResetToken(model.Token);

            if (user == null)
            {
                throw new AppException("Invalid token");
            }

            if (user.ResetTokenExpiresAt < DateTime.UtcNow)
            {
                throw new AppException("Invalid token");
            }

            return(true);
        }