class RouteSubscriber in Lightweight Directory Access Protocol (LDAP) 8.3
Same name and namespace in other branches
- 8.4 ldap_authentication/src/Routing/RouteSubscriber.php \Drupal\ldap_authentication\Routing\RouteSubscriber
Class RouteSubscriber.
@package Drupal\ldap_authentication\Routing Listens to the dynamic route events.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\ldap_authentication\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
- ldap_authentication.services.yml in ldap_authentication/
ldap_authentication.services.yml - ldap_authentication/ldap_authentication.services.yml
1 service uses RouteSubscriber
File
- ldap_authentication/
src/ Routing/ RouteSubscriber.php, line 16
Namespace
Drupal\ldap_authentication\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
if ($route = $collection
->get('user.pass')) {
$route
->setRequirement('_custom_access', '\\Drupal\\ldap_authentication\\Routing\\RouteSubscriber::validateResetPasswordAllowed');
}
}
/**
* Checks whether password reset is allowed.
*
* @return \Drupal\Core\Access\AccessResultInterface
* Show password or not.
*/
public static function validateResetPasswordAllowed() {
$user = \Drupal::currentUser();
if ($user
->isAnonymous()) {
if (\Drupal::config('ldap_authentication.settings')
->get('authenticationMode') == LdapAuthenticationConfiguration::MODE_MIXED) {
return AccessResult::allowed();
}
// Hide reset password for anonymous users if LDAP-only authentication and
// password updates are disabled, otherwise show.
if (\Drupal::config('ldap_authentication.settings')
->get('passwordOption') == LdapAuthenticationConfiguration::$passwordFieldAllow) {
return AccessResult::allowed();
}
else {
return AccessResult::forbidden();
}
}
else {
return AccessResult::forbidden();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriber:: |
public static | function | Checks whether password reset is allowed. | |
RouteSubscriberBase:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | 5 |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |