Skip to content

Commit

Permalink
backport: MS-2756 backport to v15.15.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Janos Pribelszki committed Mar 15, 2024
1 parent 52fe7b7 commit 6d25edc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" : "53.15.1.1"
},
"autoload" : {
"psr-4" : {
Expand Down
19 changes: 18 additions & 1 deletion models/classes/LtiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -111,8 +113,23 @@ 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;
Expand Down
8 changes: 4 additions & 4 deletions models/classes/TaoLtiSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 6d25edc

Please sign in to comment.