Skip to content
Snippets Groups Projects
Commit 7c333091 authored by Fabian de Rijk's avatar Fabian de Rijk
Browse files

Moved some code to a sperate module for better use and easier upgrade

parent c2943501
No related branches found
No related tags found
No related merge requests found
Showing
with 56 additions and 40 deletions
......@@ -2,6 +2,4 @@ name: 'Office 365 - SSO'
type: module
description: 'Enable SSO with Office365'
core_version_requirement: ^8 || ^9
package: 'Microsoft Office'
dependencies:
- externalauth:externalauth
\ No newline at end of file
package: 'Microsoft Office'
\ No newline at end of file
......@@ -17,6 +17,4 @@ function o365_sso_install() {
*/
function o365_sso_update_9001() {
module_set_weight('o365_sso', 100);
\Drupal::service('module_installer')->install(['externalauth']);
}
o365_sso.settings_form:
title: 'SSO settings'
route_name: o365_sso.settings_form
base_route: o365.settings_form
o365_sso.settings_form:
path: '/admin/config/system/o365/settings/sso'
defaults:
_form: '\Drupal\o365_sso\Form\SettingsForm'
_title: 'SSO Settings'
requirements:
_permission: 'access o365 sso settings page'
options:
_admin_route: TRUE
o365_sso.login_controller_login:
path: '/o365/login'
defaults:
......
......@@ -3,8 +3,3 @@ services:
class: Drupal\o365_sso\Routing\UserLoginFormRouteSubscriber
tags:
- { name: event_subscriber }
o365_sso.user_login_event:
class: Drupal\o365_sso\EventSubscriber\UserLoginEventSubscriber
arguments: [ '@config.factory', '@o365.graph' ]
tags:
- { name: event_subscriber }
name: 'Office 365 - SSO User'
type: module
description: 'Enable syncing of user data.'
core_version_requirement: ^8 || ^9
package: 'Microsoft Office'
dependencies:
- externalauth:externalauth
- o365_sso:o365_sso
\ No newline at end of file
<?php
/**
* @file
* Install and update hooks for the o365_sso_user module.
*/
/**
* Implements hook_install().
*/
function o365_sso_user_install() {
module_set_weight('o365_sso_user', 100);
}
o365_sso.settings_form:
title: 'SSO Settings'
route_name: o365_sso.settings_form
o365_sso_user.settings_form:
title: 'SSO user Settings'
route_name: o365_sso_user.settings_form
description: 'SSO settings for the Office 365 Connector module'
parent: o365.settings_form
weight: 0
o365_sso_user.settings_form:
title: 'SSO user settings'
route_name: o365_sso_user.settings_form
base_route: o365.settings_form
access o365 sso user settings page:
title: 'Access SSO User settings page'
o365_sso_user.settings_form:
path: '/admin/config/system/o365/settings/sso'
defaults:
_form: '\Drupal\o365_sso_user\Form\SettingsForm'
_title: 'SSO Settings'
requirements:
_permission: 'access o365 sso user settings page'
options:
_admin_route: TRUE
services:
o365_sso_user.login_event:
class: Drupal\o365_sso_user\EventSubscriber\UserLoginEventSubscriber
arguments: [ '@config.factory', '@o365.graph' ]
tags:
- { name: event_subscriber }
<?php
namespace Drupal\o365_sso\EventSubscriber;
namespace Drupal\o365_sso_user\EventSubscriber;
use Drupal\Core\Extension\ModuleHandler;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\externalauth\Event\ExternalAuthEvents;
......@@ -39,7 +38,7 @@ class UserLoginEventSubscriber implements EventSubscriberInterface {
* The graph service.
*/
public function __construct(ConfigFactoryInterface $config_factory, GraphService $o365_graph) {
$this->config = $config_factory->get('o365_sso.settings');
$this->config = $config_factory->get('o365_sso_user.settings');
$this->graphService = $o365_graph;
}
......@@ -47,11 +46,8 @@ class UserLoginEventSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$moduleHandler = \Drupal::service('module_handler');
if ($moduleHandler->moduleExists('externalauth')) {
$events[ExternalAuthEvents::LOGIN][] = ['updateUserData'];
return $events;
}
$events[ExternalAuthEvents::LOGIN][] = ['updateUserData'];
return $events;
}
/**
......
<?php
namespace Drupal\o365_sso\Form;
namespace Drupal\o365_sso_user\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
......@@ -15,7 +15,7 @@ class SettingsForm extends ConfigFormBase {
*/
protected function getEditableConfigNames() {
return [
'o365_sso.settings',
'o365_sso_user.settings',
];
}
......@@ -30,7 +30,7 @@ class SettingsForm extends ConfigFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('o365_sso.settings');
$config = $this->config('o365_sso_user.settings');
$form['use_graph_data'] = [
'#type' => 'checkbox',
'#title' => $this->t('Use user data from Graph API'),
......@@ -59,7 +59,7 @@ class SettingsForm extends ConfigFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this->config('o365_sso.settings')
$this->config('o365_sso_user.settings')
->set('use_graph_data', $form_state->getValue('use_graph_data'))
->set('graph_data_mapping', $form_state->getValue('graph_data_mapping'))
->save();
......
......@@ -4,5 +4,5 @@ description: 'Office 365 Connector module'
core_version_requirement: ^8 || ^9
package: 'Microsoft Office'
dependencies:
- o365:o365_sso
- o365_sso:o365_sso
- oauth2_client:oauth2_client
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment