Commit 657af9ec authored by Balint Pekker's avatar Balint Pekker Committed by Brad Jones
Browse files

Issue #3289642 by phenaproxima, balintpekker, bradjones1: Automated Drupal 10 compatibility fixes

parent a307d661
Loading
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -13,12 +13,6 @@
      "phpspec/prophecy-phpunit": "^2"
    },
    "license": "GPL-2.0-or-later",
    "authors": [
        {
            "name": "Mateu Aguiló Bosch",
            "email": "mateu.aguilo.bosch@gmail.com"
        }
    ],
    "extra": {
        "drush": {
            "services": {
+4 −2
Original line number Diff line number Diff line
<?php

use Drupal\simple_oauth\Entities\AccessTokenEntity;
use Drupal\user\Entity\User;
/**
 * @file
 * Hooks specific to the Simple OAuth module.
@@ -21,9 +23,9 @@ use Drupal\user\UserInterface;
 *
 * @see \Drupal\simple_oauth\Entities\AccessTokenEntity::convertToJWT()
 */
function hook_simple_oauth_private_claims_alter(&$private_claims, \Drupal\simple_oauth\Entities\AccessTokenEntity $access_token_entity) {
function hook_simple_oauth_private_claims_alter(&$private_claims, AccessTokenEntity $access_token_entity) {
  $user_id = $access_token_entity->getUserIdentifier();
  $user = \Drupal\user\Entity\User::load($user_id);
  $user = User::load($user_id);
  $private_claims = [
    'mail' => $user->getEmail(),
    'username' => $user->getAccountName(),
+1 −1
Original line number Diff line number Diff line
name: Simple OAuth & OpenID Connect
type: module
description: 'The OAuth 2.0 Authorization Framework'
core_version_requirement: '^8 || ^9'
core_version_requirement: '^9 || ^10'
package: Authentication
configure: oauth2_token.settings
dependencies:
+2 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ function simple_oauth_update_8403() {
function simple_oauth_update_8404() {
  $use_implicit = \Drupal::config('simple_oauth_extras.settings')->get('use_implicit');
  if ($use_implicit === NULL) {
    $config_path = drupal_get_path('module', 'simple_oauth') . '/config/install';
    $config_path = \Drupal::service('extension.list.module')->getPath('simple_oauth') . '/config/install';
    // Because of custom config_path, we don't call service here.
    $source = new FileStorage($config_path);
    $config_default = $source->read('simple_oauth.settings');
@@ -94,6 +94,7 @@ function simple_oauth_update_8404() {
  ];
  $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  foreach ($field_names as $field_name) {
    /** @var \Drupal\Core\Field\BaseFieldDefinition $field_definition */
    $field_definition = $entity_definition_update_manager->getFieldStorageDefinition($field_name, 'consumer');
    // If simple_oauth_extras was installed, we need at least to update field provider.
    if ($field_definition && $deleted) {
+4 −2
Original line number Diff line number Diff line
@@ -155,15 +155,17 @@ function simple_oauth_form_consumer_form_alter(array &$form, FormStateInterface
  // Add a custom submit behavior.
  $form['#entity_builders'][] = 'simple_oauth_form_consumer_form_submit';

  /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
  $entity_type_manager = \Drupal::service('entity_type.manager');
  // Remove automatic roles and administrator roles.
  unset($form['roles']['widget']['#options'][RoleInterface::ANONYMOUS_ID]);
  unset($form['roles']['widget']['#options'][RoleInterface::AUTHENTICATED_ID]);
  // Get the admin role.
  $admin_roles = $entity_type_manager->getStorage('user_role')
  $admin_roles = $entity_type_manager
    ->getStorage('user_role')
    ->getQuery()
    ->accessCheck()
    ->condition('is_admin', TRUE)
    ->accessCheck()
    ->execute();
  $default_value = reset($admin_roles);
  unset($form['roles']['widget']['#options'][$default_value]);
Loading