Problem/Motivation

When editing a node, the URL path settings section contains a link to admin/config/search/path/patterns, regardless of whether the authorised user has the administer pathauto permission.

Clicking on this link can then lead the user to an access denied page.

It would be better UX to only display the link if the user has the administer pathauto permission.

This may effect other administration pages where pathauto can insert this link.

Verified to affect current 8.x-1.x as well as 8.x-1.0-beta1.

Proposed resolution

Only provide the link to administer pathauto when the user has the permission to access it.

Remaining tasks

Identify all pages where pathauto can insert this link. For each, only insert it if the user has administer pathauto permission.

User interface changes

See above.

API changes

None.

Data model changes

None.

Comments

Eli-T created an issue. See original summary.

lpsolit’s picture

Assigned: Unassigned » lpsolit
Status: Active » Needs review
StatusFileSize
new1.04 KB
berdir’s picture

Status: Needs review » Needs work
+++ b/src/PathautoWidget.php
@@ -43,11 +43,16 @@ class PathautoWidget extends PathWidget {
 
+    $description = $this->t('Uncheck this to create a custom alias below.');
+    if (\Drupal::currentUser()->hasPermission('administer pathauto')) {
+      $description .= $this->t(' <a href="@admin_link">Configure URL alias patterns.</a>', ['@admin_link' => Url::fromRoute('entity.pathauto_pattern.collection')->toString()]);
+    }

Thanks. Combining translatable strings is always tricky, it gets *really* complicated with things like right to left languages like russian.

The safe option is to define two separate t() calls, one with the link and one without.

lpsolit’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB

  • Berdir committed 39fa13d on 8.x-1.x authored by LpSolit
    Issue #2840749 by LpSolit, Eli-T: Users are invited to Configure URL...
berdir’s picture

Status: Needs review » Fixed

Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.