TYPO3CMS
9.5
Main Page
Related Pages
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Files
File List
File Members
All
$
d
e
r
u
Functions
Variables
$
e
r
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Pages
BackendUserSessionRepository.php
Go to the documentation of this file.
1
<?php
2
namespace
TYPO3\CMS\Beuser\Domain\Repository
;
3
4
/*
5
* This file is part of the TYPO3 CMS project.
6
*
7
* It is free software; you can redistribute it and/or modify it under
8
* the terms of the GNU General Public License, either version 2
9
* of the License, or any later version.
10
*
11
* For the full copyright and license information, please read the
12
* LICENSE.txt file that was distributed with this source code.
13
*
14
* The TYPO3 project - inspiring people to share!
15
*/
16
17
use
TYPO3\CMS\Beuser\Domain\Model\BackendUser
;
18
use
TYPO3\CMS\Core\Authentication\AbstractUserAuthentication
;
19
use
TYPO3\CMS\Core\Session\Backend\SessionBackendInterface
;
20
use
TYPO3\CMS\Core\Session\SessionManager
;
21
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
22
use
TYPO3\CMS\Extbase\Persistence\Repository
;
23
28
class
BackendUserSessionRepository
extends
Repository
29
{
35
public
function
findAllActive
()
36
{
37
$sessionBackend = $this->
getSessionBackend
();
38
$allSessions = $sessionBackend->getAll();
39
40
// Map array to correct keys
41
$allSessions = array_map(
42
function
($session) {
43
return
[
44
'id'
=> $session[
'ses_id'
],
// this is the hashed sessionId
45
'ip'
=> $session[
'ses_iplock'
],
46
'timestamp'
=> $session[
'ses_tstamp'
],
47
'ses_userid'
=> $session[
'ses_userid'
]
48
];
49
},
50
$allSessions
51
);
52
53
// Sort by timestamp
54
usort($allSessions,
function
($session1, $session2) {
55
return
$session1[
'timestamp'
] <=> $session2[
'timestamp'
];
56
});
57
58
return
$allSessions;
59
}
60
67
public
function
findByBackendUser
(
BackendUser
$backendUser)
68
{
69
$allActive = $this->
findAllActive
();
70
71
return
array_filter(
72
$allActive,
73
function
($session) use ($backendUser) {
74
return
(
int
)$session[
'ses_userid'
] === $backendUser->
getUid
();
75
}
76
);
77
}
78
84
public
function
switchBackToOriginalUser
(
AbstractUserAuthentication
$authentication)
85
{
86
$sessionBackend = $this->
getSessionBackend
();
87
$sessionId = $this->
getBackendSessionId
();
88
$sessionBackend->update(
89
$sessionId,
90
[
91
'ses_userid'
=> $authentication->user[
'ses_backuserid'
],
92
'ses_backuserid'
=> 0
93
]
94
);
95
}
96
100
protected
function
getBackendSessionId
(): string
101
{
102
return
$GLOBALS
[
'BE_USER'
]->id;
103
}
104
108
protected
function
getSessionBackend
():
SessionBackendInterface
109
{
110
return
GeneralUtility::makeInstance(SessionManager::class)->getSessionBackend(
'BE'
);
111
}
112
}
TYPO3\CMS\Beuser\Domain\Repository\BackendUserSessionRepository\getSessionBackend
SessionBackendInterface getSessionBackend()
Definition:
BackendUserSessionRepository.php:108
TYPO3\CMS\Core\Session\SessionManager
Definition:
SessionManager.php:37
TYPO3\CMS\Beuser\Domain\Repository\BackendUserSessionRepository\findAllActive
array findAllActive()
Definition:
BackendUserSessionRepository.php:35
TYPO3\CMS\Beuser\Domain\Repository\BackendUserSessionRepository
Definition:
BackendUserSessionRepository.php:29
TYPO3\CMS\Beuser\Domain\Repository
Definition:
BackendUserGroupRepository.php:2
TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject\getUid
int getUid()
Definition:
AbstractDomainObject.php:62
TYPO3\CMS\Core\Session\Backend\SessionBackendInterface
Definition:
SessionBackendInterface.php:26
TYPO3\CMS\Extbase\Persistence\Repository
Definition:
Repository.php:23
TYPO3\CMS\Beuser\Domain\Repository\BackendUserSessionRepository\switchBackToOriginalUser
switchBackToOriginalUser(AbstractUserAuthentication $authentication)
Definition:
BackendUserSessionRepository.php:84
$GLOBALS
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition:
ext_localconf.php:5
TYPO3\CMS\Beuser\Domain\Model\BackendUser
Definition:
BackendUser.php:22
TYPO3\CMS\Core\Utility\GeneralUtility
Definition:
GeneralUtility.php:45
TYPO3\CMS\Beuser\Domain\Repository\BackendUserSessionRepository\findByBackendUser
array findByBackendUser(BackendUser $backendUser)
Definition:
BackendUserSessionRepository.php:67
TYPO3\CMS\Beuser\Domain\Repository\BackendUserSessionRepository\getBackendSessionId
string getBackendSessionId()
Definition:
BackendUserSessionRepository.php:100
TYPO3\CMS\Core\Authentication\AbstractUserAuthentication
Definition:
AbstractUserAuthentication.php:51
doxygen
typo3
sysext
beuser
Classes
Domain
Repository
BackendUserSessionRepository.php
Generated on Tue Oct 5 2021 01:57:01 for TYPO3CMS by
1.8.18