Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auth
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lib
unicaen
auth
Commits
a19f7e00
Commit
a19f7e00
authored
Mar 28, 2014
by
Laurent Lecluse
Browse files
Options
Downloads
Patches
Plain Diff
Ajout du mécanisme de rapatriement de l'utilisateur courant
parent
2d8707d2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Module.php
+4
-1
4 additions, 1 deletion
Module.php
src/UnicaenAuth/Service/UserContext.php
+100
-0
100 additions, 0 deletions
src/UnicaenAuth/Service/UserContext.php
with
104 additions
and
1 deletion
Module.php
+
4
−
1
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
This diff is collapsed.
Click to expand it.
src/UnicaenAuth/Service/UserContext.php
0 → 100644
+
100
−
0
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment