diff --git a/composer.json b/composer.json index d15c2e4d..d5c0e2ed 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,7 @@ "oat-sa/lib-lti1p3-ags": "^1.2", "oat-sa/lib-lti1p3-core": "^6.0.0", "oat-sa/generis" : ">=15.22", - "oat-sa/tao-core" : ">=50.24.6" + "oat-sa/tao-core" : ">=54.8.0" }, "autoload" : { "psr-4" : { diff --git a/models/classes/LtiService.php b/models/classes/LtiService.php index 192fbfc0..968a8491 100644 --- a/models/classes/LtiService.php +++ b/models/classes/LtiService.php @@ -35,6 +35,8 @@ use oat\oatbox\service\ConfigurableService; use oat\oatbox\service\ServiceManager; use oat\oatbox\session\SessionService; +use oat\tao\model\session\Context\TenantDataSessionContext; +use oat\tao\model\session\Context\UserDataSessionContext; use oat\tao\model\TaoOntology; use oat\taoLti\models\classes\LtiMessages\LtiErrorMessage; use oat\taoLti\models\classes\user\Lti1p3User; @@ -111,10 +113,27 @@ public function createLti1p3Session( $ltiUser->setRegistrationId($registration->getIdentifier()); - $session = TaoLtiSession::fromVersion1p3($ltiUser); + $contexts = []; + if ($clientId) { + $userId = $messagePayload->getUserIdentity(); + $clientIdParts = explode('-', $clientId); + $contexts = [ + new UserDataSessionContext( + $userId->getIdentifier(), + $userId->getIdentifier(), + $userId->getName(), + $userId->getEmail(), + $userId->getLocale() + ), + new TenantDataSessionContext(end($clientIdParts)) + ]; + } + + $session = TaoLtiSession::fromVersion1p3($ltiUser, $contexts); $this->getServiceLocator()->propagate($session); + return $session; } catch (LtiInvalidVariableException $e) { $this->logInfo($e->getMessage()); diff --git a/models/classes/TaoLtiSession.php b/models/classes/TaoLtiSession.php index 063dcf33..21b6d9a0 100644 --- a/models/classes/TaoLtiSession.php +++ b/models/classes/TaoLtiSession.php @@ -37,14 +37,14 @@ class TaoLtiSession extends common_session_DefaultSession /** @var string */ private $version = self::VERSION_LTI_1P1; - public function __construct(LtiUserInterface $user) + public function __construct(LtiUserInterface $user, array $contexts = []) { - parent::__construct($user); + parent::__construct($user, $contexts); } - public static function fromVersion1p3(LtiUserInterface $user): self + public static function fromVersion1p3(LtiUserInterface $user, array $contexts = []): self { - $session = new self($user); + $session = new self($user, $contexts); $session->version = self::VERSION_LTI_1P3;