Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sarahphp1 created an issue. See original summary.

0Sarah0Al’s picture

Issue summary: View changes
gapple’s picture

Currently this could be achieved by altering the persistent_login.user_tokens_list route in a custom module to modify the access requirements, but there isn't an option within Persistent Login itself.

https://www.drupal.org/docs/8/api/routing-system/altering-existing-route...

0Sarah0Al’s picture

Thanks!

I used the code from the link you provided to deny access to 'persistent_login.user_tokens_list' route and hide the local task from users.

class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {

    // Note that the second parameter of setRequirement() is a string.
    if ($route = $collection->get('persistent_login.user_tokens_list')) {
      $route->setRequirement('_access', 'FALSE');
    }
  }
}

This will work for now thank you.

0Sarah0Al’s picture

Status: Active » Fixed
josebc’s picture

Status: Needs review » Needs work
0Sarah0Al’s picture

Awesome..
It works perfectly.

I can see the new added permission here admin/people/permissions

Thanks alot :)

gapple’s picture

As noted in #2500903: Provide individual information on a user's created tokens, my intent for the page is to provide a user more information about any active sessions and enable them to be revoked, like many other services allow.

I think this is something valuable for a user to have control over, so I am unlikely to introduce an option within the module which can remove that ability from users.

gapple’s picture

Status: Needs work » Closed (works as designed)
truls1502’s picture

Status: Closed (works as designed) » Reviewed & tested by the community

#6 works.

@gapple, I understand your point of view very well. But when the client is asking about it to specific roles, it would be nice to have it included rather than adding an extra patch for it.

I hope if you could possibly to reconsider to add it included the module.

W01F’s picture

+1 for making this a configurable option. Sometimes we want to keep options/buttons/etc. as simple as possible, and in this case (for the most part) the user has already agreed to/selected to keep an active session open by checking "Remember me".

Mohammed J. Razem’s picture

Title: Hide user's local task » Provide a permission for users to see "Persistent Logins" tab in their profiles

Changing the title of the issue to be more descriptive.

@gapple your point makes sense. However, this feature request does NOT remove this option - rather makes it optional for the site owner to decide whether to show it or not for their users.

I think this is an important user experience improvement for Site Builders who do not want to write custom hooks to remove this option if they do not want to show it their users.

gapple’s picture

Permissions are opt-in for site builders to grant as needed, while I think access to this feature should be enabled-by-default. I don't think it would be correct for the module to assign the permission by default to existing (on module install) and new roles - at least I'm not aware of any other modules that currently do so.

Rajab Natshah’s picture

Status: Needs review » Reviewed & tested by the community
Rajab Natshah’s picture

Tested in many projects.

jonathanshaw’s picture

Permissions are opt-in for site builders to grant as needed, while I think access to this feature should be enabled-by-default. I don't think it would be correct for the module to assign the permission by default to existing (on module install) and new roles

I see granting it to the authenticated role on existing installs (which is all the patch does) as unproblematic.

I think the feature is especially valuable right now because without #2500903: Provide individual information on a user's created tokens this page is not very useful and rather puzzling for end users.

+++ b/persistent_login.permissions.yml
@@ -0,0 +1,3 @@
+access persistent logins tab:

I don't think the permission name should include 'tab'. Better something more generic like 'access persistent login records' or 'access persistent login history' or 'access persistent login information'.

Rajab Natshah’s picture

Hopping to have this nice feature committed into the module.

Rajab Natshah’s picture