-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christian Eßl
committed
Mar 12, 2021
1 parent
6541de1
commit 74f7904
Showing
6 changed files
with
72 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ChristianEssl\Impersonate\Authentication; | ||
|
||
use TYPO3\CMS\Core\Authentication\AuthenticationService; | ||
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; | ||
use TYPO3\CMS\Core\Database\ConnectionPool; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class AuthService extends AuthenticationService | ||
{ | ||
public function getUser() | ||
{ | ||
$uid = (int)GeneralUtility::_GET('uid'); | ||
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) | ||
->getQueryBuilderForTable('fe_users'); | ||
$queryBuilder | ||
->select('*') | ||
->from('fe_users') | ||
->where($queryBuilder->expr()->eq( | ||
'uid', | ||
$queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT) | ||
)); | ||
|
||
return $queryBuilder->execute()->fetch(); | ||
} | ||
|
||
public function authUser(array $user): int | ||
{ | ||
return (int) (GeneralUtility::_GET('route') === '/impersonate/login' && | ||
$GLOBALS['BE_USER'] instanceof BackendUserAuthentication && | ||
$GLOBALS['BE_USER']->isAdmin()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters