Merge branch 'login_procedure' into 'develop'

Login procedure

See merge request !24
parents a9417f9a 1321689f
......@@ -4,6 +4,14 @@ epal_is_logged_in:
_controller: '\Drupal\epal\Controller\Login::helloWorld'
requirements:
_access: 'TRUE'
epal_entityapi_test:
path: '/epal/entityapi/test'
options:
_auth: [ 'basic_auth' ]
requirements:
_user_is_logged_in: 'TRUE'
defaults:
_controller: '\Drupal\epal\Controller\Login::testQuery'
epal_auth_test:
path: 'epal/auth/test'
options:
......
......@@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityFieldManagerInterface;
/**
* Controller routines for page example routes.
......@@ -18,18 +19,22 @@ use Drupal\Core\Controller\ControllerBase;
class Login extends ControllerBase {
protected $query_factory;
protected $entityTypeManager;
protected $entityFieldManager;
public function __construct(EntityTypeManagerInterface $entityTypeManager, QueryFactory $query_factory) {
public function __construct(EntityTypeManagerInterface $entityTypeManager, QueryFactory $query_factory, EntityFieldManagerInterface $entityFieldManager) {
// public function __construct(QueryFactory $query_factory) {
$this->entityTypeManager = $entityTypeManager;
$this->query_factory = $query_factory;
$this->entityFieldManager = $entityFieldManager;
}
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.manager'),
$container->get('entity.query')
$container->get('entity_type.manager'),
$container->get('entity.query'),
$container->get('entity_field.manager')
);
}
......@@ -67,7 +72,57 @@ public function helloWorld() {
}
return array_values($arrayToReturn);
}
public function object_2_array($result) {
$array = array();
foreach ($result as $key=>$value)
{
if (is_object($value))
{
$array[$key]=$this->object_2_array($value);
}
elseif (is_array($value))
{
$array[$key]=$this->object_2_array($value);
}
else
{
$array[$key]=$value;
}
}
return $array;
}
public function testQuery() {
$query = $this->query_factory->get('epal_users');
// ->condition('status', 1);
$scids = $query->execute();
$epalUsers_storage = $this->entityTypeManager->getStorage('epal_users');
$epalUsers = $epalUsers_storage->loadMultiple($scids);
$arrayToReturn = array();
$j=0;
foreach ($epalUsers as $epalUser) {
// print_r($epalUser);
// $arrayToReturn[$j] = implode(",", $this->object_2_array($epalUser->id) );
$arrayToReturn[$j] = $epalUser->user_id->target_id;
$j++;
/* foreach ($epalUser->name as $delta => $item) {
$arrayToReturn[$delta] = $item->value;
} */
/* array_push($arrayToReturn,
$epalUser->surname->getValue()); */
}
// return array_values($arrayToReturn);
$response = new JsonResponse($arrayToReturn);
return $response;
}
public function basicQuery() {
return [
......
langcode: en
uuid: 761245c9-c12c-4bad-baae-b6659bdcd614
langcode: el
status: true
dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module:
- basic_auth
- epalreadydata
- rest
- serialization
- user
_core:
default_config_hash: x1x9jIC8SmXp0wDILOEs5_1lxH47q3VCokKYxEu4U-8
id: coursefields
label: coursefields
module: views
......@@ -21,8 +30,12 @@ display:
position: 0
display_options:
access:
type: none
options: { }
type: role
options:
role:
authenticated: authenticated
administrator: administrator
applicant: applicant
cache:
type: tag
options: { }
......@@ -217,6 +230,7 @@ display:
- 'languages:language_interface'
- request_format
- url.query_args
- user.roles
tags: { }
rest_export_1:
display_plugin: rest_export
......@@ -246,10 +260,13 @@ display:
name:
alias: ''
raw_output: true
auth:
- basic_auth
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- request_format
- user.roles
tags: { }
langcode: en
uuid: de8212d8-4c94-4132-bb3d-8761c9746d82
langcode: el
status: true
dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module:
- basic_auth
- epalreadydata
- hal
- rest
- serialization
- user
_core:
default_config_hash: hfXJdCjR9GthaynAMVZvAHOKY-_kuI4Qz9NyNFMYnbE
id: coursesectorlist
label: courseSectorList
module: views
......@@ -22,8 +31,12 @@ display:
position: 0
display_options:
access:
type: none
options: { }
type: role
options:
role:
authenticated: authenticated
administrator: administrator
applicant: applicant
cache:
type: tag
options: { }
......@@ -380,6 +393,7 @@ display:
- 'languages:language_content'
- 'languages:language_interface'
- url.query_args
- user.roles
tags: { }
rest_export_1:
display_plugin: rest_export
......@@ -417,10 +431,13 @@ display:
options:
items_per_page: 0
offset: 0
auth:
- basic_auth
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- request_format
- user.roles
tags: { }
langcode: en
uuid: 1cff8f27-9685-419a-a482-2005548b23f4
langcode: el
status: true
dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module:
- basic_auth
- epalreadydata
- hal
- rest
- serialization
- user
_core:
default_config_hash: X-Hp7xhmfNgEXwpE0VYHvI6BIYiDJDxGhGXtNwpeiCs
id: coursesperschool
label: coursesperschool
module: views
......@@ -22,8 +31,12 @@ display:
position: 0
display_options:
access:
type: none
options: { }
type: role
options:
role:
authenticated: authenticated
administrator: administrator
applicant: applicant
cache:
type: tag
options: { }
......@@ -457,6 +470,7 @@ display:
- 'languages:language_interface'
- url
- url.query_args
- user.roles
tags: { }
page_1:
display_plugin: page
......@@ -466,6 +480,7 @@ display:
display_options:
display_extenders: { }
path: coursesperschool
enabled: false
cache_metadata:
max-age: 0
contexts:
......@@ -473,6 +488,7 @@ display:
- 'languages:language_interface'
- url
- url.query_args
- user.roles
tags: { }
rest_export_1:
display_plugin: rest_export
......@@ -516,6 +532,8 @@ display:
options:
items_per_page: 0
offset: 0
auth:
- basic_auth
cache_metadata:
max-age: -1
contexts:
......@@ -523,4 +541,5 @@ display:
- 'languages:language_interface'
- request_format
- url
- user.roles
tags: { }
langcode: en
uuid: 18e12b86-cc8a-4fec-8006-d8b1c9965d0a
langcode: el
status: true
dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module:
- basic_auth
- epalreadydata
- rest
- serialization
- user
_core:
default_config_hash: jN_EIEThsJ2oXHaytnygkFnn2JT0t0QskuCm77DjmZk
id: regional_epal
label: regional_epal
module: views
......@@ -21,8 +30,12 @@ display:
position: 0
display_options:
access:
type: none
options: { }
type: role
options:
role:
authenticated: authenticated
administrator: administrator
applicant: applicant
cache:
type: tag
options: { }
......@@ -387,6 +400,7 @@ display:
- 'languages:language_interface'
- request_format
- url.query_args
- user.roles
tags: { }
rest_export_1:
display_plugin: rest_export
......@@ -422,10 +436,13 @@ display:
name_1:
alias: region_name
raw_output: true
auth:
- basic_auth
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- request_format
- user.roles
tags: { }
langcode: en
uuid: 7f4711bc-7dc6-447b-bb8e-4093837c6665
langcode: el
status: true
dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module:
- basic_auth
- epalreadydata
- hal
- rest
- serialization
- user
_core:
default_config_hash: 5rM-pSfc1ywl4-ufHeAQsKiVGcBMDcz4RLfYmMeVGfo
id: sectorlist
label: sectorList
module: views
......@@ -22,8 +31,12 @@ display:
position: 0
display_options:
access:
type: none
options: { }
type: role
options:
role:
authenticated: authenticated
administrator: administrator
applicant: applicant
cache:
type: tag
options: { }
......@@ -222,6 +235,7 @@ display:
- 'languages:language_content'
- 'languages:language_interface'
- url.query_args
- user.roles
tags: { }
rest_export_1:
display_plugin: rest_export
......@@ -247,10 +261,13 @@ display:
hal_json: hal_json
json: json
path: sectorfields/list
auth:
- basic_auth
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- request_format
- user.roles
tags: { }
langcode: en
uuid: 303db0c1-04ad-4087-882e-7d487988017e
langcode: el
status: true
dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module:
- basic_auth
- epalreadydata
- hal
- rest
- serialization
- user
_core:
default_config_hash: fK5R5e8RHCNJLfhNG1jGBtHtSy6rExm-UquW3n8og9w
id: sectorsperschool
label: sectorsperschool
module: views
......@@ -22,8 +31,12 @@ display:
position: 0
display_options:
access:
type: none
options: { }
type: role
options:
role:
authenticated: authenticated
administrator: administrator
applicant: applicant
cache:
type: tag
options: { }
......@@ -421,6 +434,7 @@ display:
- 'languages:language_content'
- 'languages:language_interface'
- url
- user.roles
tags: { }
page_1:
display_plugin: page
......@@ -430,12 +444,14 @@ display:
display_options:
display_extenders: { }
path: sectorsperschool
enabled: false
cache_metadata:
max-age: 0
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- user.roles
tags: { }
rest_export_1:
display_plugin: rest_export
......@@ -476,6 +492,8 @@ display:
options:
items_per_page: 0
offset: 0
auth:
- basic_auth
cache_metadata:
max-age: -1
contexts:
......@@ -483,4 +501,5 @@ display:
- 'languages:language_interface'
- request_format
- url
- user.roles
tags: { }
entity.oauthost_config.add_form:
route_name: entity.oauthost_config.add_form
title: 'Add OAuthOST Config'
appears_on:
- entity.oauthost_config.collection
entity.oauthost_session.add_form:
route_name: entity.oauthost_session.add_form
title: 'Add OAuthOST Session'
appears_on:
- entity.oauthost_session.collection
# OAuthOST Config menu items definition
entity.oauthost_config.collection:
title: 'OAuthOST Config list'
route_name: entity.oauthost_config.collection
description: 'List OAuthOST Config entities'
parent: system.admin_structure
weight: 100
oauthost_config.admin.structure.settings:
title: OAuthOST Config settings
description: 'Configure OAuthOST Config entities'
route_name: oauthost_config.settings
parent: system.admin_structure
# OAuthOST Session menu items definition
entity.oauthost_session.collection:
title: 'OAuthOST Session list'
route_name: entity.oauthost_session.collection
description: 'List OAuthOST Session entities'
parent: system.admin_structure
weight: 100
oauthost_session.admin.structure.settings:
title: OAuthOST Session settings
description: 'Configure OAuthOST Session entities'
route_name: oauthost_session.settings
parent: system.admin_structure
# OAuthOST Config routing definition
oauthost_config.settings_tab:
route_name: oauthost_config.settings
title: 'Settings'
base_route: oauthost_config.settings
entity.oauthost_config.canonical:
route_name: entity.oauthost_config.canonical
base_route: entity.oauthost_config.canonical
title: 'View'
entity.oauthost_config.edit_form:
route_name: entity.oauthost_config.edit_form
base_route: entity.oauthost_config.canonical
title: 'Edit'
entity.oauthost_config.delete_form:
route_name: entity.oauthost_config.delete_form
base_route: entity.oauthost_config.canonical
title: Delete
weight: 10
# OAuthOST Session routing definition
oauthost_session.settings_tab:
route_name: oauthost_session.settings
title: 'Settings'
base_route: oauthost_session.settings
entity.oauthost_session.canonical:
route_name: entity.oauthost_session.canonical
base_route: entity.oauthost_session.canonical
title: 'View'
entity.oauthost_session.edit_form:
route_name: entity.oauthost_session.edit_form
base_route: entity.oauthost_session.canonical
title: 'Edit'
entity.oauthost_session.delete_form:
route_name: entity.oauthost_session.delete_form
base_route: entity.oauthost_session.canonical
title: Delete
weight: 10
add oauthost config entities:
title: 'Create new OAuthOST Config entities'
administer oauthost config entities:
title: 'Administer OAuthOST Config entities'
description: 'Allow to access the administration form to configure OAuthOST Config entities.'
restrict access: true
delete oauthost config entities:
title: 'Delete OAuthOST Config entities'
edit oauthost config entities:
title: 'Edit OAuthOST Config entities'
access oauthost config overview:
title: 'Access the OAuthOST Config overview page'
view published oauthost config entities:
title: 'View published OAuthOST Config entities'
view unpublished oauthost config entities:
title: 'View unpublished OAuthOST Config entities'
add oauthost session entities:
title: 'Create new OAuthOST Session entities'
administer oauthost session entities:
title: 'Administer OAuthOST Session entities'
description: 'Allow to access the administration form to configure OAuthOST Session entities.'
restrict access: true
delete oauthost session entities:
title: 'Delete OAuthOST Session entities'
edit oauthost session entities:
title: 'Edit OAuthOST Session entities'
access oauthost session overview:
title: 'Access the OAuthOST Session overview page'
view published oauthost session entities:
title: 'View published OAuthOST Session entities'
view unpublished oauthost session entities:
title: 'View unpublished OAuthOST Session entities'
oauthost.log_in_go:
path: /oauth/login
defaults:
_controller: '\Drupal\oauthost\Controller\OAuthLogin::loginGo'
requirements:
_access: 'TRUE'
oauthost.callback_log_in:
path: /oauth/cb
defaults:
......
services:
authentication.oauthost:
class: Drupal\oauthost\Authentication\Provider\OAuthOSTConsumer
arguments: ['@config.factory', '@entity_type.manager', '@logger.channel.oauth']
tags:
- { name: authentication_provider, provider_id: ostauthentication_provider, priority: 100 }
logger.channel.oauth:
parent: 'logger.channel_base'
arguments: ['oauthost']
<?php
/**
* @file
* Contains oauthost_config.page.inc.
*
* Page callback for OAuthOST Config entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for OAuthOST Config templates.
*
* Default template: oauthost_config.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the user information and any
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_oauthost_config(array &$variables) {