Revoke membership and roles previously assigned by authorization

Created on 3 November 2023, 8 months ago
Updated 18 February 2024, 4 months ago

Problem/Motivation

Group membership is granted and revoked based on mappings. This conflicts with manual assignment.

Steps to reproduce

Proposed resolution

Use the user.data service to store the mappings. This will allow every profile to revoke group:roles previously granted correctly.

$user = \Drupal::currentUser();

// Define an array of role => profile.
$roles= [
  'group:1' => [
    'team--administrator' => 'profile_a',
  ],
  'group:3' => [
      'team--teacher' => 'profile_b',
  ],
  'group:5' => [
    'team--staff' => 'profile_b',
  ],
];

// Store the array as user data.
\Drupal::service('user.data')->set('authorization_group', $user->id(), 'roles', $roles);

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bluegeek9

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024