Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
auth
Commits
a19f7e00
Commit
a19f7e00
authored
Mar 28, 2014
by
Laurent Lécluse
Browse files
Ajout du mécanisme de rapatriement de l'utilisateur courant
parent
2d8707d2
Changes
2
Show whitespace changes
Inline
Side-by-side
Module.php
View file @
a19f7e00
...
...
@@ -152,6 +152,9 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
return
$form
;
},
),
'invokables'
=>
array
(
'authUserContext'
=>
'\UnicaenAuth\Service\UserContext'
),
);
}
}
\ No newline at end of file
src/UnicaenAuth/Service/UserContext.php
0 → 100644
View file @
a19f7e00
<?php
namespace
UnicaenAuth\Service
;
use
Zend\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
use
ZfcUser\Entity\UserInterface
;
use
UnicaenAuth\Entity\Ldap\People
;
/**
*
*
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/
class
UserContext
implements
ServiceLocatorAwareInterface
{
/**
* @var ServiceLocatorInterface
*/
protected
$sl
;
/**
* @var mixed
*/
protected
$identity
;
/**
*
* @return mixed
*/
protected
function
getIdentity
()
{
if
(
null
===
$this
->
identity
)
{
$authenticationService
=
$this
->
sl
->
get
(
'Zend\Authentication\AuthenticationService'
);
if
(
$authenticationService
->
hasIdentity
())
{
$this
->
identity
=
$authenticationService
->
getIdentity
();
}
}
return
$this
->
identity
;
}
/**
* Retourne l'utilisateur BDD courant
*
* @return UserInterface
*/
public
function
getDbUser
()
{
if
((
$identity
=
$this
->
getIdentity
()))
{
if
(
isset
(
$identity
[
'db'
])
&&
$identity
[
'db'
]
instanceof
UserInterface
)
{
return
$identity
[
'db'
];
}
}
return
null
;
}
/**
* Retourne l'utilisateur LDAP courant
*
* @return People
*/
public
function
getLdapUser
()
{
if
((
$identity
=
$this
->
getIdentity
()))
{
if
(
isset
(
$identity
[
'ldap'
])
&&
$identity
[
'ldap'
]
instanceof
People
)
{
return
$identity
[
'ldap'
];
}
}
return
null
;
}
/**
* Set service locator
*
* @param ServiceLocatorInterface $serviceLocator
* @return self
*/
public
function
setServiceLocator
(
ServiceLocatorInterface
$serviceLocator
)
{
$this
->
sl
=
$serviceLocator
;
return
$this
;
}
/**
* Get service locator
*
* @return ServiceLocatorInterface
*/
public
function
getServiceLocator
()
{
return
$this
->
sl
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment