From 3e31e60106f029ce4829cafa9988fbe3117dfe4d Mon Sep 17 00:00:00 2001 From: Lucas Bartholemy Date: Wed, 22 May 2024 20:30:43 +0200 Subject: [PATCH] Fixed Serialization Problem --- authclient/GithubAuth.php | 45 +++++++++++++++++---------------------- docs/CHANGELOG.md | 4 ++++ module.json | 2 +- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/authclient/GithubAuth.php b/authclient/GithubAuth.php index aa21a90..accf1be 100644 --- a/authclient/GithubAuth.php +++ b/authclient/GithubAuth.php @@ -24,6 +24,25 @@ protected function defaultViewOptions() ]; } + /** + * @inheritdoc + */ + protected function initUserAttributes() + { + $attributes = parent::initUserAttributes(); + + if (isset($attributes['name'])) { + $parts = mb_split(' ', $attributes['name'], 2); + if (isset($parts[0])) { + $attributes['firstname'] = $parts[0]; + } + if (isset($parts[1])) { + $attributes['lastname'] = $parts[1]; + } + } + return $attributes; + } + /** * @inheritdoc */ @@ -31,32 +50,6 @@ protected function defaultNormalizeUserAttributeMap() { return [ 'username' => 'login', - 'firstname' => function ($attributes) { - if (!isset($attributes['name'])) { - return ''; - } - $parts = mb_split(' ', $attributes['name'], 2); - if (isset($parts[0])) { - return $parts[0]; - } - return ''; - }, - 'lastname' => function ($attributes) { - if (!isset($attributes['name'])) { - return ''; - } - $parts = mb_split(' ', $attributes['name'], 2); - if (isset($parts[1])) { - return $parts[1]; - } - return ''; - }, - 'email' => function ($attributes) { - if (empty($attributes['email'])) { - throw new NotFoundHttpException(Yii::t('AuthGithubModule.base', 'Please add a valid email address to your GitHub account to be able to proceed.')); - } - return $attributes['email']; - }, ]; } } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index fe3a566..ee29117 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +1.0.1 (May 22, 2024) +--------------------- +- Fix: Serialization Problem + 1.0.0 (March 2, 2022) --------------------- - Initial release diff --git a/module.json b/module.json index a0d1431..7d0c601 100644 --- a/module.json +++ b/module.json @@ -4,7 +4,7 @@ "description": "Integrating GitHub Sign-In (OAuth 2.0).", "keywords": [ ], - "version": "1.0.0", + "version": "1.0.1", "homepage": "https://github.com/humhub-contrib/auth-github", "humhub": { "minVersion": "1.6"