2022-11-30 01:27:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* https://www.d3data.de
|
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace D3\Webauthn\Application\Model;
|
|
|
|
|
2022-12-04 00:24:28 +01:00
|
|
|
use D3\TestingTools\Production\IsMockable;
|
2022-12-09 22:23:32 +01:00
|
|
|
use OxidEsales\Eshop\Core\Language;
|
|
|
|
use OxidEsales\Eshop\Core\Request;
|
|
|
|
use OxidEsales\Eshop\Core\Session;
|
2022-12-04 00:24:28 +01:00
|
|
|
use OxidEsales\Eshop\Core\UtilsServer;
|
2022-11-30 01:27:05 +01:00
|
|
|
|
|
|
|
class WebauthnAfterLogin
|
|
|
|
{
|
2022-12-04 00:24:28 +01:00
|
|
|
use IsMockable;
|
|
|
|
|
2022-12-09 22:23:32 +01:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setDisplayProfile(): void
|
2022-11-30 01:27:05 +01:00
|
|
|
{
|
2023-01-21 13:50:18 +01:00
|
|
|
$session = d3GetOxidDIC()->get('d3ox.webauthn.'.Session::class);
|
2022-11-30 01:27:05 +01:00
|
|
|
|
2023-01-21 13:50:18 +01:00
|
|
|
$sProfile = d3GetOxidDIC()->get('d3ox.webauthn.'.Request::class)
|
2022-12-09 22:23:32 +01:00
|
|
|
->getRequestEscapedParameter('profile') ?:
|
|
|
|
$session->getVariable(WebauthnConf::WEBAUTHN_ADMIN_PROFILE);
|
|
|
|
|
|
|
|
$session->deleteVariable(WebauthnConf::WEBAUTHN_ADMIN_PROFILE);
|
2022-11-30 01:27:05 +01:00
|
|
|
|
2023-01-21 13:50:18 +01:00
|
|
|
$myUtilsServer = d3GetOxidDIC()->get('d3ox.webauthn.'.UtilsServer::class);
|
2022-11-30 01:27:05 +01:00
|
|
|
|
|
|
|
if (isset($sProfile)) {
|
2022-12-09 22:23:32 +01:00
|
|
|
$aProfiles = $session->getVariable("aAdminProfiles");
|
2022-11-30 01:27:05 +01:00
|
|
|
if ($aProfiles && isset($aProfiles[$sProfile])) {
|
|
|
|
// setting cookie to store last locally used profile
|
|
|
|
$myUtilsServer->setOxCookie("oxidadminprofile", $sProfile . "@" . implode("@", $aProfiles[$sProfile]), time() + 31536000);
|
2022-12-09 22:23:32 +01:00
|
|
|
$session->setVariable("profile", $aProfiles[$sProfile]);
|
2022-11-30 01:27:05 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//deleting cookie info, as setting profile to default
|
|
|
|
$myUtilsServer->setOxCookie("oxidadminprofile", "", time() - 3600);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2022-12-09 22:23:32 +01:00
|
|
|
public function changeLanguage(): void
|
2022-11-30 01:27:05 +01:00
|
|
|
{
|
2023-01-21 13:50:18 +01:00
|
|
|
$myUtilsServer = d3GetOxidDIC()->get('d3ox.webauthn.'.UtilsServer::class);
|
|
|
|
$session = d3GetOxidDIC()->get('d3ox.webauthn.'.Session::class);
|
2022-12-09 22:23:32 +01:00
|
|
|
|
2022-11-30 01:27:05 +01:00
|
|
|
// languages
|
2023-01-21 13:50:18 +01:00
|
|
|
$iLang = d3GetOxidDIC()->get('d3ox.webauthn.'.Request::class)
|
2022-12-09 22:23:32 +01:00
|
|
|
->getRequestEscapedParameter('chlanguage') ?:
|
|
|
|
$session->getVariable(WebauthnConf::WEBAUTHN_ADMIN_CHLANGUAGE);
|
|
|
|
|
|
|
|
$session->deleteVariable(WebauthnConf::WEBAUTHN_ADMIN_CHLANGUAGE);
|
2022-11-30 01:27:05 +01:00
|
|
|
|
2023-01-21 13:50:18 +01:00
|
|
|
$language = d3GetOxidDIC()->get('d3ox.webauthn.'.Language::class);
|
2022-12-09 22:23:32 +01:00
|
|
|
$aLanguages = $language->getAdminTplLanguageArray();
|
2022-11-30 01:27:05 +01:00
|
|
|
|
|
|
|
if (!isset($aLanguages[$iLang])) {
|
|
|
|
$iLang = key($aLanguages);
|
|
|
|
}
|
|
|
|
|
|
|
|
$myUtilsServer->setOxCookie("oxidadminlanguage", $aLanguages[$iLang]->abbr, time() + 31536000);
|
2022-12-09 22:23:32 +01:00
|
|
|
$language->setTplLanguage($iLang);
|
2022-11-30 01:27:05 +01:00
|
|
|
}
|
2022-12-13 22:24:33 +01:00
|
|
|
}
|