Skip to content

Commit

Permalink
Merge pull request #17 from tkiehne/master
Browse files Browse the repository at this point in the history
Drupal 10.2 version
  • Loading branch information
tkiehne authored Feb 6, 2024
2 parents a540550 + 124f281 commit e61f9b1
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"require": {
"php": ">=8.1"
},
"conflict": {
"drush/drush": "<10.2"
},
"license": "GPL-3.0-or-later",
"minimum-stability": "dev"
}
2 changes: 2 additions & 0 deletions src/Controller/LogoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class LogoutController extends ControllerBase {
*
* @return array
* A render array.
*
* @todo user_logout will be deprecated in 11.0.
*/
public function logout(): array {
$title = $this->t('Logout');
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/UwAuthLogoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class UwAuthLogoutController extends ControllerBase {

/**
* Log user out of Drupal, and redirect to web login.
*
* @todo user_logout will be deprecated in 11.0.
*/
public function logout(): TrustedRedirectResponse {
user_logout();
Expand Down
15 changes: 12 additions & 3 deletions src/EventSubscriber/UwAuthSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\user\Entity\User;
use Drupal\user\RoleInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\LocalRedirectResponse;
use Drupal\uwauth\Debug;
Expand Down Expand Up @@ -143,7 +144,9 @@ protected function createUser(string $username, AttributeBagInterface $attribute
if (!\in_array($domain, $validDomains)) {
$mail = "$username@uwauth.invalid";
}
$account = User::create([
$user_storage = $this->entityTypeManager->getStorage('user');
/** @var \Drupal\user\UserInterface $account */
$account = $user_storage->create([
'init' => $mail,
'mail' => $mail,
'name' => $username,
Expand Down Expand Up @@ -298,7 +301,9 @@ protected function getUserByName(string $username): User|false {
return reset($accounts);
}


/**
* {@inheritdoc}
*/
public function handle(RequestEvent $event): void {
$this->debug->message($this->t('User id: @id', ['@id' => $this->currentUser->id()]));
if ($this->isLoggedIn()
Expand Down Expand Up @@ -470,7 +475,11 @@ private function syncRoles(AccountInterface $account): void {
return;
}

$roles_existing = user_roles(TRUE);
$roles = $this->entityTypeManager->getStorage('user_role')->loadMultiple();
if (!empty($roles) && isset($roles[RoleInterface::ANONYMOUS_ID])) {
unset($roles[RoleInterface::ANONYMOUS_ID]);
}
$roles_existing = \array_keys($roles);
$roles_assigned = $account->getRoles(TRUE);
$mapped_roles = $this->mapGroupsRoles($account);

Expand Down
4 changes: 2 additions & 2 deletions uwauth.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ name: 'UW Auth'
description: 'Provides authentication and role assignment with Shibboleth, and UW Groups or Active Directory'
package: Web services
type: module
version: '3.0.2'
core_version_requirement: ^9 || ^10
version: '3.0.3'
core_version_requirement: ^10.2
2 changes: 1 addition & 1 deletion uwauth.module
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function uwauth_help($route_name, RouteMatchInterface $route_match) {
$output .= '<p>' . t('For portability purposes, externally managed groups are mapped to Drupal roles. This mapping function allows for changes in group names, and sources without having to change permissions within Drupal.') . '</p>';
$output .= '<p>' . t('Each row within the text box represents a group to role map entry. A group can only be mapped to a single role, as the group name is used as an internal identifier. Groups cannot be mapped to builtin Drupal roles. So, if you want to give a group, admin privileges, you will need to create a role with those privileges.') . '</p>';
$output .= '<h3>' . t('History') . '</h3>';
$output .= '<p>' . t('Developed by John Yocum for UW DEOHS. Source code history, releases, etc. available from') . ' ' . '<a href=https://github.com/jtyocum/drupal8-uwauth>https://github.com/jtyocum/drupal8-uwauth</a>.' . '</p>';
$output .= '<p>' . t('Developed by John Yocum for UW DEOHS. Source code history, releases, etc. available from') . ' ' . '<a href=https://github.com/deohs/uwauth>https://github.com/deohs/uwauth</a>.' . '</p>';
return $output;
}
}

0 comments on commit e61f9b1

Please sign in to comment.