-
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.
- Loading branch information
Showing
4 changed files
with
218 additions
and
3 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 |
---|---|---|
|
@@ -185,6 +185,17 @@ public static function getUserData(Container $container, int $id, array $options | |
} | ||
$groups = implode(',', $groups); | ||
|
||
$phone = ''; | ||
if ($member->phone) { | ||
$phone = $member->phone; | ||
} | ||
if ($member->gsm) { | ||
if ($phone) { | ||
$phone .= '/'; | ||
} | ||
$phone .= $member->gsm; | ||
} | ||
|
||
return [ | ||
'id' => $member->id, | ||
'identifier' => $member->id, //nextcloud | ||
|
@@ -199,7 +210,7 @@ public static function getUserData(Container $container, int $id, array $options | |
'country' => $member->country, | ||
'zip' => $member->zipcode, | ||
'city' => $member->town, | ||
'phone' => $member->phone . '/' . $member->gsm, | ||
'phone' => $phone, | ||
|
||
'status' => $member->status, | ||
'state' => $etat_adhesion ? 'true' : 'false', | ||
|
@@ -234,7 +245,7 @@ public static function mergeOptions(Config $config, $client_id, array $oauth_sco | |
// 'email' => '[email protected]', 'emailVerified' => NULL, 'phone' => NULL, | ||
// 'address' => NULL, 'country' => NULL, 'region' => NULL, 'city' => NULL, 'zip' => NULL | ||
|
||
private static function stripAccents(string $str): string | ||
public static function stripAccents(string $str): string | ||
{ | ||
//FIXME: there is probably a better way to go. | ||
//try with something like transliterator_transliterate("Any-Latin; Latin-ASCII; [^a-zA-Z0-9\.\ -_] Remove;", $str); | ||
|
87 changes: 87 additions & 0 deletions
87
tests/GaletteOAuth2/Authorization/tests/units/UserHelper.php
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2021-2024 The Galette Team | ||
* | ||
* This file is part of Galette OAuth2 plugin (https://galette-community.github.io/plugin-oauth2/). | ||
* | ||
* Galette is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Galette is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Galette OAuth2 plugin. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace GaletteOauth2\Authorization\tests\units; | ||
|
||
use Galette\GaletteTestCase; | ||
|
||
/** | ||
* UserHelper tests | ||
* | ||
* @author Johan Cwiklinski <[email protected]> | ||
*/ | ||
class UserHelper extends GaletteTestCase | ||
{ | ||
protected int $seed = 20230324120838; | ||
|
||
/** | ||
* Test stripAccents | ||
* | ||
* @return void | ||
*/ | ||
public function testStripAccents(): void | ||
{ | ||
/** @var \Galette\Core\Plugins */ | ||
global $plugins; | ||
|
||
$str = "éè"; | ||
$this->assertSame('ee', \GaletteOAuth2\Authorization\UserHelper::stripAccents($str)); | ||
} | ||
|
||
/** | ||
* Test getUserData | ||
* | ||
* @return void | ||
*/ | ||
public function testGetUserData(): void | ||
{ | ||
global $container; | ||
|
||
$adh1 = $this->getMemberOne(); | ||
$user_data = \GaletteOAuth2\Authorization\UserHelper::getUserData( | ||
$container, | ||
$adh1->id, | ||
[] | ||
); | ||
|
||
$this->assertSame( | ||
[ | ||
'id' => $adh1->id, | ||
'identifier' => $adh1->id, | ||
'displayName' => $adh1->sname, | ||
'username' => 'r.durand', | ||
'userName' => 'r.durand', | ||
'name' => 'r.durand', | ||
'email' => $adh1->email, | ||
'mail' => $adh1->email, | ||
'language' => $adh1->language, | ||
'country' => $adh1->country, | ||
'zip' => $adh1->zipcode, | ||
'city' => $adh1->town, | ||
'phone' => $adh1->phone, | ||
'status' => $adh1->status, | ||
'state' => 'false', | ||
'groups' => 'non-member' | ||
], | ||
$user_data | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2021-2024 The Galette Team | ||
* | ||
* This file is part of Galette OAuth2 plugin (https://galette-community.github.io/plugin-oauth2/). | ||
* | ||
* Galette is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Galette is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Galette OAuth2 plugin. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* Bootstrap tests file for OAuth2 plugin | ||
* | ||
* @author Johan Cwiklinski <[email protected]> | ||
*/ | ||
|
||
define('GALETTE_PLUGINS_PATH', __DIR__ . '/../../'); | ||
$basepath = '../../../galette/'; | ||
|
||
include_once '../../../tests/TestsBootstrap.php'; |