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

Guest user lti1p3 lang detection #365

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 13 additions & 1 deletion models/classes/Platform/Service/Oidc/Lti1p3UserAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function getUserIdentity(string $userId): UserIdentity

$email = $this->getPropertyValue($user, UserRdf::PROPERTY_MAIL);

$locale = $this->getPropertyValue($user, UserRdf::PROPERTY_DEFLG);
$locale = $this->detectLocale($user);

return new UserIdentity($login, trim($fullName), $email, $firstName, $lastName, null, $locale);
}
Expand All @@ -79,6 +79,18 @@ private function getPropertyValue(User $user, string $propertyName): ?string
return $user->getPropertyValues($propertyName)[0] ?? null;
}

private function detectLocale(User $user): ?string
{
if (
!empty($this->getPropertyValue($user, UserRdf::PROPERTY_LOGIN))
|| !defined('DEFAULT_ANONYMOUS_INTERFACE_LANG')
) {
return $this->getPropertyValue($user, UserRdf::PROPERTY_DEFLG);
} else {
return DEFAULT_ANONYMOUS_INTERFACE_LANG;
}
}

private function getUserService(): UserService
{
return $this->getServiceLocator()->get(UserService::SERVICE_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ public function testAnonymousOrGuestUser(): void
new UserIdentity(
'userId#123456',
'',
''
'',
null,
null,
null,
defined('DEFAULT_ANONYMOUS_INTERFACE_LANG')
? DEFAULT_ANONYMOUS_INTERFACE_LANG
: DEFAULT_LANG
)
),
$this->subject->authenticate($registration, 'userId#123456')
Expand All @@ -132,14 +138,16 @@ private function expectUser(
[UserRdf::PROPERTY_FIRSTNAME],
[UserRdf::PROPERTY_LASTNAME],
[UserRdf::PROPERTY_MAIL],
[UserRdf::PROPERTY_LOGIN],
[UserRdf::PROPERTY_DEFLG]
)
->willReturnOnConsecutiveCalls(
[$login],
[$firstName],
[$lastName],
[$email],
[$locale],
[$login],
[$locale]
);

$this->userService
Expand Down
Loading