-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uses Galette data without reworking it per default. Add a word in README file on upgrading to this BC breaking release
- Loading branch information
Showing
6 changed files
with
70 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,13 +106,15 @@ public static function logout(Container $container): void | |
* @param int $id User ID | ||
* @param string $acl Requested authorization | ||
* @param array|string $scopes Scopes | ||
* @param bool $legacy Legacy mode for data | ||
* | ||
* @return array | ||
* @throws UserAuthorizationException | ||
* @throws \DI\DependencyException | ||
* @throws \DI\NotFoundException | ||
* @throws \Throwable | ||
*/ | ||
public static function getUserData(Container $container, int $id, string $acl, array|string $scopes): array | ||
public static function getUserData(Container $container, int $id, string $acl, array|string $scopes, bool $legacy = false): array | ||
{ | ||
/** @var Db $zdb */ | ||
$zdb = $container->get('zdb'); | ||
|
@@ -160,25 +162,29 @@ public static function getUserData(Container $container, int $id, string $acl, a | |
); | ||
} | ||
|
||
//FIXME: I really doubt reworking names is a good idea outside a specific usage | ||
$nameExplode = preg_split('/[\\s,-]+/', $member->name); | ||
if (count($nameExplode) > 0) { | ||
$nameFPart = $nameExplode[0]; | ||
//too short? | ||
if (mb_strlen($nameFPart) < 4 && count($nameExplode) > 1) { | ||
$nameFPart .= $nameExplode[1]; | ||
$login = $member->login; | ||
|
||
if ($legacy === true) { | ||
//FIXME: I really doubt reworking names is a good idea outside a specific usage | ||
$nameExplode = preg_split('/[\\s,-]+/', $member->name); | ||
if (count($nameExplode) > 0) { | ||
$nameFPart = $nameExplode[0]; | ||
//too short? | ||
if (mb_strlen($nameFPart) < 4 && count($nameExplode) > 1) { | ||
$nameFPart .= $nameExplode[1]; | ||
} | ||
} else { | ||
$nameFPart = $member->name; | ||
} | ||
} else { | ||
$nameFPart = $member->name; | ||
} | ||
|
||
//Normalized format s.name (example mail usage : [email protected] ) | ||
//FIXME: why don't use email directly? | ||
$norm_login = sprintf( | ||
'%s.%s', | ||
mb_substr(self::stripAccents($member->surname), 0, 1), | ||
self::stripAccents($nameFPart) | ||
); | ||
//Normalized format s.name (example mail usage : [email protected] ) | ||
//FIXME: why don't use email directly? | ||
$login = sprintf( | ||
'%s.%s', | ||
mb_substr(self::stripAccents($member->surname), 0, 1), | ||
self::stripAccents($nameFPart) | ||
); | ||
} | ||
|
||
//FIXME: be compliant with OpenID-Connect (see https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims) | ||
$oauth_data = [ | ||
|
@@ -187,8 +193,8 @@ public static function getUserData(Container $container, int $id, string $acl, a | |
'identifier' => $member->id, //nextcloud | ||
'name' => $member->sfullname, //OpenID-Connect | ||
'displayName' => $member->sname, | ||
'username' => $norm_login, //FIXME: $member->login, | ||
'userName' => $norm_login, //FIXME: $member->login, | ||
'username' => $login, | ||
'userName' => $login, | ||
'email' => $member->email, | ||
'mail' => $member->email, | ||
'locale' => $member->language, //OpenID-Connect | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters