|
|
@@ -17,7 +17,9 @@ use \TYPO3\CMS\Core\Authentication\AbstractAuthenticationService;
|
|
|
class OtAuthenticationService extends AbstractAuthenticationService
|
|
|
{
|
|
|
|
|
|
- CONST DOMAIN = 'https://api.opentalent.fr';
|
|
|
+// CONST DOMAIN = 'https://api.opentalent.fr';
|
|
|
+ CONST DOMAIN = 'https://api.preprod.opentalent.fr';
|
|
|
+
|
|
|
CONST API_URI = self::DOMAIN . '/api/';
|
|
|
CONST LOGIN_URI = self::API_URI . 'login_check';
|
|
|
CONST GET_USER_DATA_URI = self::API_URI . 'user/datafortypo3';
|
|
|
@@ -25,7 +27,7 @@ class OtAuthenticationService extends AbstractAuthenticationService
|
|
|
CONST LOGOUT_URI = self::API_URI . 'logout';
|
|
|
|
|
|
// Cookies'domain needs to be the same that the api's cookies, or guzzle will ignore them.
|
|
|
- CONST COOKIE_DOMAIN = 'opentalent.fr';
|
|
|
+ CONST COOKIE_DOMAIN = '.opentalent.fr';
|
|
|
|
|
|
CONST PRODUCT_MAPPING = [
|
|
|
"school-standard" => 1, // Association writer basic
|
|
|
@@ -237,11 +239,7 @@ class OtAuthenticationService extends AbstractAuthenticationService
|
|
|
$value = $cookie->getValue();
|
|
|
$expires = $cookie->getExpires();
|
|
|
$path = $cookie->getPath();
|
|
|
- if ($_SERVER['SERVER_ADDR'] == '127.0.0.1') {
|
|
|
- $domain = $_SERVER['SERVER_NAME'];
|
|
|
- } else {
|
|
|
- $domain = $cookie->getDomain();
|
|
|
- }
|
|
|
+ $domain = self::COOKIE_DOMAIN;
|
|
|
$secure = $cookie->getSecure();
|
|
|
$httpOnly = $cookie->getHttpOnly();
|
|
|
|
|
|
@@ -415,15 +413,14 @@ class OtAuthenticationService extends AbstractAuthenticationService
|
|
|
// Unset the session cookies (SESSID and BEARER)
|
|
|
if (isset($_COOKIE['BEARER'])) {
|
|
|
unset($_COOKIE['BEARER']);
|
|
|
- setcookie('BEARER', '', time()-1, '/', self::COOKIE_DOMAIN);
|
|
|
+ $this->unset_cookie('BEARER');
|
|
|
}
|
|
|
if (isset($_COOKIE['SFSESSID'])) {
|
|
|
unset($_COOKIE['SFSESSID']);
|
|
|
- setcookie('SFSESSID', '', time()-1, '/', self::COOKIE_DOMAIN);
|
|
|
+ $this->unset_cookie('SFSESSID');
|
|
|
}
|
|
|
|
|
|
$this->pObj->logoff();
|
|
|
-
|
|
|
return true;
|
|
|
|
|
|
} catch (RequestException $e) {
|
|
|
@@ -431,6 +428,19 @@ class OtAuthenticationService extends AbstractAuthenticationService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Unset a cookie by reducing its expiration date
|
|
|
+ *
|
|
|
+ * @param string $name
|
|
|
+ */
|
|
|
+ protected function unset_cookie(string $name) {
|
|
|
+ $res = setcookie($name, '', time() - 1, '/', self::COOKIE_DOMAIN);
|
|
|
+ if (!$res) {
|
|
|
+ $this->writeLogMessage('Error while unsetting ' . $name . ' cookie');
|
|
|
+ }
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Writes log message. Destination log depends on the current system mode.
|
|
|
* For FE the function writes to the admin panel log. For BE messages are
|