isActive()) { // the message passed to this exception is meant to be displayed to the user throw new CustomUserMessageAccountStatusException('Your user account has been deactivated by an Admin, please follow up with your Admin to reactivate it.'); } } public function checkPostAuth(UserInterface $user): void { $dt = new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE'])); $dt->sub(DateInterval::createFromDateString('120 days')); if (!$user instanceof AppUser) { return; } if (!\in_array('ROLE_USER', $user->getRoles())) { throw new AccessDeniedException('You do not have access to this system, please contact an Admin'); } // user account is expired, the user may be notified if ($user->getPasswordChanged() < $dt) { $this->addFlash('warning', 'Your password has expired. Please change it now!'); $this->redirectToRoute('app_profile'); } } }