added redirect at login

This commit is contained in:
naomi 2022-07-05 13:58:10 +01:00
parent de3a79209b
commit 801c69fa06

View File

@ -9,6 +9,25 @@ use Drupal\Core\Access\AccessResult;
use Drupal\opencase_cases\Entity\OCCase; use Drupal\opencase_cases\Entity\OCCase;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\opencase_cases\Entity\OCCaseProvision; use Drupal\opencase_cases\Entity\OCCaseProvision;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
/**
* Implements hook_form_FORM_ID_alter().
*/
function opencase_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['#submit'][] = 'opencase_user_login_form_submit';
}
/**
* If the user does not have permissions to see all cases, then when the login they are
* redirected to a view of just their own cases.
*/
function opencase_user_login_form_submit($form, FormStateInterface $form_state) {
if (!\Drupal::currentUser()->hasPermission('view published case entities')) {
$form_state->setRedirectUrl(Url::fromRoute('view.cases_by_provider.page_1'));
}
}
/** /**
* Implements hook_element_info_alter(). * Implements hook_element_info_alter().