Skip to content
Snippets Groups Projects

Feature upgrade to9 lts

Merged Kevin Ditscheid requested to merge feature_UpgradeTo9LTS into master
Compare and
65 files
+ 2568
1487
Compare changes
  • Side-by-side
  • Inline
Files
65
@@ -35,7 +35,7 @@ use SGalinski\SgAccount\Service\BaseService;
use TYPO3\CMS\Core\Authentication\AbstractUserAuthentication;
use TYPO3\CMS\Core\Service\AbstractService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
/**
* AuthService service (able to login with all email addresses of the user)
@@ -77,7 +77,7 @@ class AuthService extends AbstractService {
$this->loginData = $loginData;
$this->parentObject = $parentObject;
$this->authenticationInformation = $authenticationInformation;
$this->baseService = GeneralUtility::makeInstance(BaseService::class);
$this->baseService = GeneralUtility::makeInstance(BaseService::class, $this->parentObject);
}
/**
@@ -92,17 +92,27 @@ class AuthService extends AbstractService {
* @throws \InvalidArgumentException
*/
public function getUser() {
$userRecord = NULL;
if (!$GLOBALS['TSFE'] || !$GLOBALS['TSFE']->fe_user) {
if (!$this->parentObject) {
// The whole logic in this method is obsolete if fe_user is not accessible
return $userRecord;
return NULL;
}
if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) {
$GLOBALS['TSFE']->fe_user->fetchUserSession();
} else {
$GLOBALS['TSFE']->fe_user->fetchSessionData();
$userRecord = NULL;
$userUid = (int) GeneralUtility::_GP('viewasuser');
if ($userUid > 0) {
return $this->baseService->getUserByUid($userUid);
}
$oAuthLoginSession = $GLOBALS['TSFE']->fe_user->getKey('ses', 'oAuthLogin');
$loginHash = trim((string) GeneralUtility::_GP('loginhash'));
if ($loginHash !== '') {
$userUid = $this->baseService->getUserUidByLoginHash(
$loginHash, $this->authenticationInformation['db_user']['checkPidList']
);
return $this->parentObject->getRawUserByUid($userUid);
}
$this->parentObject->fetchUserSession();
$oAuthLoginSession = $this->parentObject->getKey('ses', 'oAuthLogin');
if ($oAuthLoginSession || $this->loginData['uname']) {
$pluginArguments = GeneralUtility::_GP('tx_sgaccount_login');
if (
@@ -112,6 +122,7 @@ class AuthService extends AbstractService {
) {
return NULL;
}
$email = (string) $this->loginData['uname'] ?: $oAuthLoginSession['id'];
if ($email !== '') {
$returnUnconfirmed = (bool) GeneralUtility::_GP('skipConfirmationCheck');
@@ -126,14 +137,8 @@ class AuthService extends AbstractService {
$userRecord = $this->parentObject->getRawUserByUid($userUid);
}
}
} elseif ($loginHash = GeneralUtility::_GP('loginhash')) {
$userUid = $this->baseService->getUserUidByLoginHash(
$loginHash, $this->authenticationInformation['db_user']['checkPidList']
);
$userRecord = $this->parentObject->getRawUserByUid($userUid);
} elseif ($userUid = GeneralUtility::_GP('viewasuser')) {
$userRecord = $this->baseService->getUserByUid($userUid);
}
return $userRecord;
}
@@ -149,24 +154,24 @@ class AuthService extends AbstractService {
* @throws \InvalidArgumentException
*/
public function authUser(array $userRecord) {
$tsfe = $this->getTyposcriptFrontendController();
if ($userRecord && GeneralUtility::_GP('viewasuser')) {
$GLOBALS['TSFE']->initializeBackendUser();
if ($GLOBALS['TSFE']->isBackendUserLoggedIn()) {
$tsfe->initializeBackendUser();
if ($tsfe->isBackendUserLoggedIn()) {
return 200;
}
}
if ($userRecord && $loginHash = GeneralUtility::_GP('loginhash')) {
if ($userRecord['tx_sgaccount_login_hash'] === $loginHash) {
$this->baseService->removeLoginHash($userRecord['uid']);
return 200;
}
}
if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) {
$GLOBALS['TSFE']->fe_user->fetchUserSession();
} else {
$GLOBALS['TSFE']->fe_user->fetchSessionData();
}
if ($userRecord && $oAuthLoginSession = $GLOBALS['TSFE']->fe_user->getKey('ses', 'oAuthLogin')) {
$this->parentObject->fetchUserSession();
if ($userRecord && $oAuthLoginSession = $this->parentObject->getKey('ses', 'oAuthLogin')) {
$arguments = $oAuthLoginSession['arguments'];
$appId = $arguments['app_id'];
$appSecret = $arguments['app_secret'];
@@ -184,14 +189,15 @@ class AuthService extends AbstractService {
$email, $this->authenticationInformation['db_user']['checkPidList']
);
if ((int) $userRecord['uid'] === $userUid) {
$GLOBALS['TSFE']->fe_user->setAndSaveSessionData('oAuthLogin', NULL);
$this->parentObject->setAndSaveSessionData('oAuthLogin', NULL);
return 200;
}
}
} catch (Google_Auth_Exception $exception) {
$GLOBALS['TSFE']->fe_user->setAndSaveSessionData('oAuthLogin', NULL);
$this->parentObject->setAndSaveSessionData('oAuthLogin', NULL);
return 100;
}
break;
case 'facebook':
try {
@@ -214,21 +220,30 @@ class AuthService extends AbstractService {
$email, $this->authenticationInformation['db_user']['checkPidList']
);
if ((int) $userRecord['uid'] === $userUid) {
$GLOBALS['TSFE']->fe_user->setAndSaveSessionData('oAuthLogin', NULL);
$this->parentObject->setAndSaveSessionData('oAuthLogin', NULL);
return 200;
}
}
} catch (FacebookSDKException $exception) {
$GLOBALS['TSFE']->fe_user->setAndSaveSessionData('oAuthLogin', NULL);
$this->parentObject->setAndSaveSessionData('oAuthLogin', NULL);
return 100;
}
break;
default:
break;
}
}
return 100;
}
/**
* @return TypoScriptFrontendController
*/
protected function getTyposcriptFrontendController(): TypoScriptFrontendController {
return $GLOBALS['TSFE'];
}
}
?>
Loading