Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add userpilot to TAO 3.x, save tenant id as session context #400

Merged
merged 6 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" : ">=54.8.0"
},
"autoload" : {
"psr-4" : {
Expand Down
21 changes: 20 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,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());
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
Loading