Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Σταύρος Παπαδάκης
e-epal
Commits
be16673c
Commit
be16673c
authored
Mar 02, 2017
by
Χάρης Παπαδόπουλος
Browse files
New oauthost module. Beta Version for testing
parent
83f1145d
Changes
39
Hide whitespace changes
Inline
Side-by-side
drupal/modules/epal/epal.routing.yml
View file @
be16673c
...
...
@@ -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
:
...
...
drupal/modules/epal/src/Controller/Login.php
View file @
be16673c
...
...
@@ -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
[
...
...
drupal/modules/epal/src/Entity/EpalUsers.php
View file @
be16673c
...
...
@@ -49,6 +49,9 @@ use Drupal\user\UserInterface;
* "name" = "name",
* "surname" = "surname",
* "taxis_taxid" = "taxis_taxid",
* "requesttoken" = "requesttoken",
* "accesstoken" = "accesstoken",
* "authtoken" = "authtoken",
* },
* links = {
* "canonical" = "/admin/structure/epal_users/{epal_users}",
...
...
@@ -60,7 +63,7 @@ use Drupal\user\UserInterface;
* field_ui_base_route = "epal_users.settings"
* )
*/
class
EpalUsers
extends
ContentEntityBase
implements
EpalUsersInterface
{
use
EntityChangedTrait
;
...
...
@@ -149,11 +152,11 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'status'
,
$published
?
TRUE
:
FALSE
);
return
$this
;
}
/**
* get / set methods for aditional fields
* get / set methods for aditional fields
*/
public
function
getDrupaluser_id
()
{
return
$this
->
get
(
'drupaluser_id'
)
->
value
;
}
...
...
@@ -162,7 +165,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'drupaluser_id'
,
$name
);
return
$this
;
}
public
function
getTaxis_userid
()
{
return
$this
->
get
(
'taxis_userid'
)
->
value
;
}
...
...
@@ -171,7 +174,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'taxis_userid'
,
$name
);
return
$this
;
}
public
function
getTaxis_taxid
()
{
return
$this
->
get
(
'taxis_taxid'
)
->
value
;
}
...
...
@@ -180,7 +183,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'taxis_taxid'
,
$name
);
return
$this
;
}
public
function
getSurname
()
{
return
$this
->
get
(
'surname'
)
->
value
;
}
...
...
@@ -189,7 +192,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'surname'
,
$name
);
return
$this
;
}
public
function
getFathername
()
{
return
$this
->
get
(
'fathername'
)
->
value
;
}
...
...
@@ -198,7 +201,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'fathername'
,
$name
);
return
$this
;
}
public
function
getMothername
()
{
return
$this
->
get
(
'mothername'
)
->
value
;
}
...
...
@@ -207,36 +210,8 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'mothername'
,
$name
);
return
$this
;
}
/*
public function getAddress() {
return $this->get('address')->value;
}
public function setAddress($name) {
$this->set('address', $name);
return $this;
}
public function getAddresstk() {
return $this->get('addresstk')->value;
}
public function setAddresstk($name) {
$this->set('addresstk', $name);
return $this;
}
public function getAddressarea() {
return $this->get('addressarea')->value;
}
public function setAddressarea($name) {
$this->set('addressarea', $name);
return $this;
}
*/
public
function
getAccesstoken
()
{
return
$this
->
get
(
'accesstoken'
)
->
value
;
}
...
...
@@ -245,7 +220,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'accesstoken'
,
$name
);
return
$this
;
}
public
function
getAuthtoken
()
{
return
$this
->
get
(
'authtoken'
)
->
value
;
}
...
...
@@ -254,7 +229,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'authtoken'
,
$name
);
return
$this
;
}
public
function
getTimelogin
()
{
return
$this
->
get
(
'timelogin'
)
->
value
;
}
...
...
@@ -263,7 +238,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'timelogin'
,
$name
);
return
$this
;
}
public
function
getTimeregistration
()
{
return
$this
->
get
(
'timeregistration'
)
->
value
;
}
...
...
@@ -272,7 +247,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'timeregistration'
,
$name
);
return
$this
;
}
public
function
getTimetokeninvalid
()
{
return
$this
->
get
(
'timetokeninvalid'
)
->
value
;
}
...
...
@@ -281,7 +256,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
$this
->
set
(
'timetokeninvalid'
,
$name
);
return
$this
;
}
public
function
getUserip
()
{
return
$this
->
get
(
'userip'
)
->
value
;
}
...
...
@@ -291,10 +266,38 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
return
$this
;
}
public
function
getRequestToken
()
{
return
$this
->
get
(
'requesttoken'
)
->
value
;
}
public
function
setRequestToken
(
$requestToken
)
{
$this
->
set
(
'requesttoken'
,
$requestToken
);
return
$this
;
}
public
function
getRequestTokenSecret
()
{
return
$this
->
get
(
'requesttokensecret'
)
->
value
;
}
public
function
setRequestTokenSecret
(
$requestTokenSecret
)
{
$this
->
set
(
'requesttokensecret'
,
$requestTokenSecret
);
return
$this
;
}
public
function
getAccessTokenSecret
()
{
return
$this
->
get
(
'accesstokensecret'
)
->
value
;
}
public
function
setAccessTokenSecret
(
$accessTokenSecret
)
{
$this
->
set
(
'accesstokensecret'
,
$accessTokenSecret
);
return
$this
;
}
/**
* {@inheritdoc}
*/
public
static
function
baseFieldDefinitions
(
EntityTypeInterface
$entity_type
)
{
$fields
=
parent
::
baseFieldDefinitions
(
$entity_type
);
...
...
@@ -348,8 +351,8 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'taxis_userid'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'User id χρήστη από taxis'
))
->
setDescription
(
t
(
'Δώσε το user id του χρήστη από taxis.'
))
...
...
@@ -369,7 +372,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'taxis_taxid'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Tax id χρήστη'
))
->
setDescription
(
t
(
'Δώσε το tax id / ΑΦΜ του χρήστη.'
))
...
...
@@ -390,7 +393,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'name'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Όνομα χρήστη'
))
->
setDescription
(
t
(
'Δώσε το όνομα χρήστη'
))
...
...
@@ -411,7 +414,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'surname'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Επώνυμο χρήστη'
))
->
setDescription
(
t
(
'Δώσε το επώνυμο του χρήστη.'
))
...
...
@@ -432,7 +435,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'fathername'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Όνομα πατέρα χρήστη'
))
->
setDescription
(
t
(
'Δώσε το όνομα του πατέρα του χρήστη.'
))
...
...
@@ -452,7 +455,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'mothername'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Όνομα μητέρας χρήστη'
))
->
setDescription
(
t
(
'Δώσε το όνομα της μητέρας χρήστη.'
))
...
...
@@ -472,74 +475,12 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
/*
$fields['address'] = BaseFieldDefinition::create('string')
->setLabel(t('Διεύθυνση κατοικίας'))
->setDescription(t('Δώσε τη διεύθυνση κατοικίας.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['addresstk'] = BaseFieldDefinition::create('string')
->setLabel(t('ΤΚ'))
->setDescription(t('Δώσε τον ΤΚ κατοικίας.'))
->setSettings(array(
'max_length' => 20,
'text_processing' => 0,
))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['addressarea'] = BaseFieldDefinition::create('string')
->setLabel(t('Πόλη/Περιοχή διεύθυνσης κατοικίας'))
->setDescription(t('Δώσε την πόλη/περιοχή διεύθυνσης.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
*/
$fields
[
'accesstoken'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Access-Token από taxis'
))
->
setDescription
(
t
(
'Access-Token από taxis.'
))
->
setSettings
(
array
(
'max_length'
=>
3
00
,
'max_length'
=>
10
00
,
'text_processing'
=>
0
,
))
->
setDefaultValue
(
''
)
...
...
@@ -554,12 +495,32 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'accesstoken_secret'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Access-Token Secret από taxis'
))
->
setDescription
(
t
(
'Access-Token Secret από taxis.'
))
->
setSettings
(
array
(
'max_length'
=>
1000
,
'text_processing'
=>
0
,
))
->
setDefaultValue
(
''
)
->
setDisplayOptions
(
'view'
,
array
(
'label'
=>
'above'
,
'type'
=>
'string'
,
'weight'
=>
-
4
,
))
->
setDisplayOptions
(
'form'
,
array
(
'type'
=>
'string_textfield'
,
'weight'
=>
-
4
,
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'authtoken'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Authorization Token'
))
->
setDescription
(
t
(
'Authorization Token που δημιουργείται από την εφαρμογή.'
))
->
setSettings
(
array
(
'max_length'
=>
3
00
,
'max_length'
=>
10
00
,
'text_processing'
=>
0
,
))
->
setDefaultValue
(
''
)
...
...
@@ -574,17 +535,57 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'requesttoken'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Oauth Request Token'
))
->
setDescription
(
t
(
'Request Token received by service provider.'
))
->
setSettings
(
array
(
'max_length'
=>
1000
,
'text_processing'
=>
0
,
))
->
setDefaultValue
(
''
)
->
setDisplayOptions
(
'view'
,
array
(
'label'
=>
'above'
,
'type'
=>
'string'
,
'weight'
=>
-
4
,
))
->
setDisplayOptions
(
'form'
,
array
(
'type'
=>
'string_textfield'
,
'weight'
=>
-
4
,
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'requesttoken_secret'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Oauth Request Token Secret'
))
->
setDescription
(
t
(
'Request Token Secret received by service provider.'
))
->
setSettings
(
array
(
'max_length'
=>
1000
,
'text_processing'
=>
0
,
))
->
setDefaultValue
(
''
)
->
setDisplayOptions
(
'view'
,
array
(
'label'
=>
'above'
,
'type'
=>
'string'
,
'weight'
=>
-
4
,
))
->
setDisplayOptions
(
'form'
,
array
(
'type'
=>
'string_textfield'
,
'weight'
=>
-
4
,
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'timelogin'
]
=
BaseFieldDefinition
::
create
(
'timestamp'
)
->
setLabel
(
t
(
'timeLogin'
))
->
setDescription
(
t
(
'timeLogin.'
))
;
$fields
[
'timeregistration'
]
=
BaseFieldDefinition
::
create
(
'timestamp'
)
->
setLabel
(
t
(
'timeRegistration'
))
->
setDescription
(
t
(
'timeRegistration.'
))
;
$fields
[
'timetokeninvalid'
]
=
BaseFieldDefinition
::
create
(
'integer'
)
->
setLabel
(
t
(
'Χρόνος σε min'
))
->
setDescription
(
t
(
'Χρόνος σε min μετά τον οποίο γίνεται το token ανενεργό.'
))
...
...
@@ -595,13 +596,15 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->
setDisplayOptions
(
'view'
,
array
(
'label'
=>
'above'
,
'type'
=>
'integer'
,
'weight'
=>
-
4
,
))
->
setDisplayOptions
(
'form'
,
array
(
'type'
=>
'integer'
,
'weight'
=>
-
4
,
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'userip'
]
=
BaseFieldDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'userIP'
))
->
setDescription
(
t
(
'userIP.'
))
...
...
@@ -621,7 +624,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'status'
]
=
BaseFieldDefinition
::
create
(
'boolean'
)
->
setLabel
(
t
(
'Publishing status'
))
->
setDescription
(
t
(
'A boolean indicating whether the Epal users is published.'
))
...
...
drupal/modules/oauthost/config/install/oauthost.settings.yml
0 → 100644
View file @
be16673c
drupal/modules/oauthost/oauthost.links.action.yml
0 → 100644
View file @
be16673c
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
drupal/modules/oauthost/oauthost.links.menu.yml
0 → 100644
View file @
be16673c
# 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
drupal/modules/oauthost/oauthost.links.task.yml
0 → 100644
View file @
be16673c
# 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