Merge branch 'login_procedure' into 'develop'

Login procedure

See merge request !24
parents a9417f9a 1321689f
...@@ -4,6 +4,14 @@ epal_is_logged_in: ...@@ -4,6 +4,14 @@ epal_is_logged_in:
_controller: '\Drupal\epal\Controller\Login::helloWorld' _controller: '\Drupal\epal\Controller\Login::helloWorld'
requirements: requirements:
_access: 'TRUE' _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: epal_auth_test:
path: 'epal/auth/test' path: 'epal/auth/test'
options: options:
......
...@@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; ...@@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityFieldManagerInterface;
/** /**
* Controller routines for page example routes. * Controller routines for page example routes.
...@@ -18,18 +19,22 @@ use Drupal\Core\Controller\ControllerBase; ...@@ -18,18 +19,22 @@ use Drupal\Core\Controller\ControllerBase;
class Login extends ControllerBase { class Login extends ControllerBase {
protected $query_factory; 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) { // public function __construct(QueryFactory $query_factory) {
$this->entityTypeManager = $entityTypeManager; $this->entityTypeManager = $entityTypeManager;
$this->query_factory = $query_factory; $this->query_factory = $query_factory;
$this->entityFieldManager = $entityFieldManager;
} }
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('entity.manager'), $container->get('entity_type.manager'),
$container->get('entity.query') $container->get('entity.query'),
$container->get('entity_field.manager')
); );
} }
...@@ -67,7 +72,57 @@ public function helloWorld() { ...@@ -67,7 +72,57 @@ public function helloWorld() {
} }
return array_values($arrayToReturn); 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() { public function basicQuery() {
return [ return [
......
langcode: en uuid: 761245c9-c12c-4bad-baae-b6659bdcd614
langcode: el
status: true status: true
dependencies: dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module: module:
- basic_auth
- epalreadydata - epalreadydata
- rest - rest
- serialization - serialization
- user
_core:
default_config_hash: x1x9jIC8SmXp0wDILOEs5_1lxH47q3VCokKYxEu4U-8
id: coursefields id: coursefields
label: coursefields label: coursefields
module: views module: views
...@@ -21,8 +30,12 @@ display: ...@@ -21,8 +30,12 @@ display:
position: 0 position: 0
display_options: display_options:
access: access:
type: none type: role
options: { } options:
role:
authenticated: authenticated
administrator: administrator
applicant: applicant
cache: cache:
type: tag type: tag
options: { } options: { }
...@@ -217,6 +230,7 @@ display: ...@@ -217,6 +230,7 @@ display:
- 'languages:language_interface' - 'languages:language_interface'
- request_format - request_format
- url.query_args - url.query_args
- user.roles
tags: { } tags: { }
rest_export_1: rest_export_1:
display_plugin: rest_export display_plugin: rest_export
...@@ -246,10 +260,13 @@ display: ...@@ -246,10 +260,13 @@ display:
name: name:
alias: '' alias: ''
raw_output: true raw_output: true
auth:
- basic_auth
cache_metadata: cache_metadata:
max-age: -1 max-age: -1
contexts: contexts:
- 'languages:language_content' - 'languages:language_content'
- 'languages:language_interface' - 'languages:language_interface'
- request_format - request_format
- user.roles
tags: { } tags: { }
langcode: en uuid: de8212d8-4c94-4132-bb3d-8761c9746d82
langcode: el
status: true status: true
dependencies: dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module: module:
- basic_auth
- epalreadydata - epalreadydata
- hal - hal
- rest - rest
- serialization - serialization
- user
_core:
default_config_hash: hfXJdCjR9GthaynAMVZvAHOKY-_kuI4Qz9NyNFMYnbE
id: coursesectorlist id: coursesectorlist
label: courseSectorList label: courseSectorList
module: views module: views
...@@ -22,8 +31,12 @@ display: ...@@ -22,8 +31,12 @@ display:
position: 0 position: 0
display_options: display_options:
access: access:
type: none type: role
options: { } options:
role:
authenticated: authenticated
administrator: administrator
applicant: applicant
cache: cache:
type: tag type: tag
options: { } options: { }
...@@ -380,6 +393,7 @@ display: ...@@ -380,6 +393,7 @@ display:
- 'languages:language_content' - 'languages:language_content'
- 'languages:language_interface' - 'languages:language_interface'
- url.query_args - url.query_args
- user.roles
tags: { } tags: { }
rest_export_1: rest_export_1:
display_plugin: rest_export display_plugin: rest_export
...@@ -417,10 +431,13 @@ display: ...@@ -417,10 +431,13 @@ display:
options: options:
items_per_page: 0 items_per_page: 0
offset: 0 offset: 0
auth:
- basic_auth
cache_metadata: cache_metadata:
max-age: -1 max-age: -1
contexts: contexts:
- 'languages:language_content' - 'languages:language_content'
- 'languages:language_interface' - 'languages:language_interface'
- request_format - request_format
- user.roles
tags: { } tags: { }
langcode: en uuid: 1cff8f27-9685-419a-a482-2005548b23f4
langcode: el
status: true status: true
dependencies: dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module: module:
- basic_auth
- epalreadydata - epalreadydata
- hal - hal
- rest - rest
- serialization - serialization
- user
_core:
default_config_hash: X-Hp7xhmfNgEXwpE0VYHvI6BIYiDJDxGhGXtNwpeiCs
id: coursesperschool id: coursesperschool
label: coursesperschool label: coursesperschool
module: views module: views
...@@ -22,8 +31,12 @@ display: ...@@ -22,8 +31,12 @@ display:
position: 0 position: 0
display_options: display_options:
access: access:
type: none type: role
options: { } options:
role:
authenticated: authenticated
administrator: administrator
applicant: applicant
cache: cache:
type: tag type: tag
options: { } options: { }
...@@ -457,6 +470,7 @@ display: ...@@ -457,6 +470,7 @@ display:
- 'languages:language_interface' - 'languages:language_interface'
- url - url
- url.query_args - url.query_args
- user.roles
tags: { } tags: { }
page_1: page_1:
display_plugin: page display_plugin: page
...@@ -466,6 +480,7 @@ display: ...@@ -466,6 +480,7 @@ display:
display_options: display_options:
display_extenders: { } display_extenders: { }
path: coursesperschool path: coursesperschool
enabled: false
cache_metadata: cache_metadata:
max-age: 0 max-age: 0
contexts: contexts:
...@@ -473,6 +488,7 @@ display: ...@@ -473,6 +488,7 @@ display:
- 'languages:language_interface' - 'languages:language_interface'
- url - url
- url.query_args - url.query_args
- user.roles
tags: { } tags: { }
rest_export_1: rest_export_1:
display_plugin: rest_export display_plugin: rest_export
...@@ -516,6 +532,8 @@ display: ...@@ -516,6 +532,8 @@ display:
options: options:
items_per_page: 0 items_per_page: 0
offset: 0 offset: 0
auth:
- basic_auth
cache_metadata: cache_metadata:
max-age: -1 max-age: -1
contexts: contexts:
...@@ -523,4 +541,5 @@ display: ...@@ -523,4 +541,5 @@ display:
- 'languages:language_interface' - 'languages:language_interface'
- request_format - request_format
- url - url
- user.roles
tags: { } tags: { }
langcode: en uuid: 18e12b86-cc8a-4fec-8006-d8b1c9965d0a
langcode: el
status: true status: true
dependencies: dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module: module:
- basic_auth
- epalreadydata - epalreadydata
- rest - rest
- serialization - serialization
- user
_core:
default_config_hash: jN_EIEThsJ2oXHaytnygkFnn2JT0t0QskuCm77DjmZk
id: regional_epal id: regional_epal
label: regional_epal label: regional_epal
module: views module: views
...@@ -21,8 +30,12 @@ display: ...@@ -21,8 +30,12 @@ display:
position: 0 position: 0
display_options: display_options:
access: access:
type: none type: role
options: { } options:
role:
authenticated: authenticated
administrator: administrator
applicant: applicant
cache: cache:
type: tag type: tag
options: { } options: { }
...@@ -387,6 +400,7 @@ display: ...@@ -387,6 +400,7 @@ display:
- 'languages:language_interface' - 'languages:language_interface'
- request_format - request_format
- url.query_args - url.query_args
- user.roles
tags: { } tags: { }
rest_export_1: rest_export_1:
display_plugin: rest_export display_plugin: rest_export
...@@ -422,10 +436,13 @@ display: ...@@ -422,10 +436,13 @@ display:
name_1: name_1:
alias: region_name alias: region_name
raw_output: true raw_output: true
auth:
- basic_auth
cache_metadata: cache_metadata:
max-age: -1 max-age: -1
contexts: contexts:
- 'languages:language_content' - 'languages:language_content'
- 'languages:language_interface' - 'languages:language_interface'
- request_format - request_format
- user.roles
tags: { } tags: { }
langcode: en uuid: 7f4711bc-7dc6-447b-bb8e-4093837c6665
langcode: el
status: true status: true
dependencies: dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module: module:
- basic_auth
- epalreadydata - epalreadydata
- hal - hal
- rest - rest
- serialization - serialization
- user
_core:
default_config_hash: 5rM-pSfc1ywl4-ufHeAQsKiVGcBMDcz4RLfYmMeVGfo
id: sectorlist id: sectorlist
label: sectorList label: sectorList
module: views module: views
...@@ -22,8 +31,12 @@ display: ...@@ -22,8 +31,12 @@ display:
position: 0 position: 0
display_options: display_options:
access: access:
type: none type: role
options: { } options:
role:
authenticated: authenticated
administrator: administrator
applicant: applicant
cache: cache:
type: tag type: tag
options: { } options: { }
...@@ -222,6 +235,7 @@ display: ...@@ -222,6 +235,7 @@ display:
- 'languages:language_content' - 'languages:language_content'
- 'languages:language_interface' - 'languages:language_interface'
- url.query_args - url.query_args
- user.roles
tags: { } tags: { }
rest_export_1: rest_export_1:
display_plugin: rest_export display_plugin: rest_export
...@@ -247,10 +261,13 @@ display: ...@@ -247,10 +261,13 @@ display:
hal_json: hal_json hal_json: hal_json
json: json json: json
path: sectorfields/list path: sectorfields/list
auth:
- basic_auth
cache_metadata: cache_metadata:
max-age: -1 max-age: -1
contexts: contexts:
- 'languages:language_content' - 'languages:language_content'
- 'languages:language_interface' - 'languages:language_interface'
- request_format - request_format
- user.roles
tags: { } tags: { }
langcode: en uuid: 303db0c1-04ad-4087-882e-7d487988017e
langcode: el
status: true status: true
dependencies: dependencies:
config:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
module: module:
- basic_auth
- epalreadydata - epalreadydata
- hal - hal
- rest - rest
- serialization - serialization
- user
_core:
default_config_hash: fK5R5e8RHCNJLfhNG1jGBtHtSy6rExm-UquW3n8og9w
id: sectorsperschool id: sectorsperschool
label: sectorsperschool label: sectorsperschool
module: views module: views
...@@ -22,8 +31,12 @@ display: ...@@ -22,8 +31,12 @@ display:
position: 0 position: 0
display_options: display_options:
access: access:
type: none type: role
options: { } options:
role:
authenticated: authenticated