diff --git a/config/config.default.php b/config/config.default.php index 323a7b2d..7e11ec8b 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -108,6 +108,8 @@ return [ 'hidden' => false, // Mark user as arrived when using this provider (optional) 'mark_arrived' => false, + // If the password field should be enabled on registration (optional) + 'enable_password' => false, // Allow registration even if disabled in config (optional) 'allow_registration' => null, // Auto join teams diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index c4596af1..6cb38fdb 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -76,6 +76,11 @@ function guest_register() } } + $oauth_enable_password = $session->get('oauth2_enable_password'); + if (!is_null($oauth_enable_password)) { + $enable_password = $oauth_enable_password; + } + if ( !auth()->can('register') // No registration permission // Not authenticated and diff --git a/src/Controllers/OAuthController.php b/src/Controllers/OAuthController.php index 0dd5aa9e..4375de76 100644 --- a/src/Controllers/OAuthController.php +++ b/src/Controllers/OAuthController.php @@ -372,6 +372,7 @@ class OAuthController extends BaseController 'email' => null, 'first_name' => null, 'last_name' => null, + 'enable_password' => false, 'allow_registration' => null, 'groups' => null, ], @@ -400,6 +401,7 @@ class OAuthController extends BaseController $this->session->set('oauth2_access_token', $accessToken->getToken()); $this->session->set('oauth2_refresh_token', $accessToken->getRefreshToken()); $this->session->set('oauth2_expires_at', $expirationTime); + $this->session->set('oauth2_enable_password', $config['enable_password']); $this->session->set('oauth2_allow_registration', $config['allow_registration']); return $this->redirector->to('/register'); diff --git a/tests/Unit/Controllers/OAuthControllerTest.php b/tests/Unit/Controllers/OAuthControllerTest.php index 20a05625..667f3e6c 100644 --- a/tests/Unit/Controllers/OAuthControllerTest.php +++ b/tests/Unit/Controllers/OAuthControllerTest.php @@ -427,6 +427,7 @@ class OAuthControllerTest extends TestCase $this->assertEquals('test-token', $this->session->get('oauth2_access_token')); $this->assertEquals('test-refresh-token', $this->session->get('oauth2_refresh_token')); $this->assertEquals(4242424242, $this->session->get('oauth2_expires_at')->unix()); + $this->assertFalse($this->session->get('oauth2_enable_password')); $this->assertEquals(null, $this->session->get('oauth2_allow_registration')); $this->assertEquals( [