From edfbc44c52966c662862e113c790ff90d3472dd0 Mon Sep 17 00:00:00 2001 From: Elias Luhr Date: Fri, 5 Jan 2024 15:05:26 +0100 Subject: [PATCH] Add separate property for social network registration --- docs/install/configuration-options.md | 5 +++++ src/User/Module.php | 4 ++++ src/User/Service/SocialNetworkAuthenticateService.php | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/install/configuration-options.md b/docs/install/configuration-options.md index f448a70..7cdf9ed 100755 --- a/docs/install/configuration-options.md +++ b/docs/install/configuration-options.md @@ -143,6 +143,11 @@ List of urls that does not require explicit data processing consent to be access Setting this attribute allows the registration process. If you set it to `false`, the module won't allow users to register by throwing a `NotFoundHttpException` if the `RegistrationController::actionRegister()` is accessed. +#### enableSocialNetworkRegistration (type: `boolean`, default: `true`) + +Setting this attribute allows the registration process via social networks. If you set it to `false`, the module won't allow users to +register. + #### enableEmailConfirmation (type: `boolean`, default: `true`) If `true`, the module will send an email with a confirmation link that user needs to click through to complete its diff --git a/src/User/Module.php b/src/User/Module.php index 0e00f58..f160d02 100755 --- a/src/User/Module.php +++ b/src/User/Module.php @@ -117,6 +117,10 @@ class Module extends BaseModule * @var bool whether to allow registration process or not */ public $enableRegistration = true; + /** + * @var bool whether to allow registration process for social network or not + */ + public $enableSocialNetworkRegistration = true; /** * @var bool whether to force email confirmation to */ diff --git a/src/User/Service/SocialNetworkAuthenticateService.php b/src/User/Service/SocialNetworkAuthenticateService.php index b990670..fad08e0 100644 --- a/src/User/Service/SocialNetworkAuthenticateService.php +++ b/src/User/Service/SocialNetworkAuthenticateService.php @@ -48,7 +48,7 @@ class SocialNetworkAuthenticateService implements ServiceInterface public function run() { $account = $this->socialNetworkAccountQuery->whereClient($this->client)->one(); - if (!$this->controller->module->enableRegistration && ($account === null || $account->user === null)) { + if (!$this->controller->module->enableSocialNetworkRegistration && ($account === null || $account->user === null)) { Yii::$app->session->setFlash('danger', Yii::t('usuario', 'Registration on this website is disabled')); $this->authAction->setSuccessUrl(Url::to(['/user/security/login']));