Make password enabled configurable via oauth settings

main
Igor Scheller 3 years ago committed by msquare
parent b5ba5f6188
commit d8076abc38

@ -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

@ -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

@ -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');

@ -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(
[

Loading…
Cancel
Save