prefill fields from oauth

This commit is contained in:
msquare 2023-08-15 12:32:31 +02:00 committed by Igor Scheller
parent 29a4b244dc
commit a2a57ec852
2 changed files with 13 additions and 24 deletions

View File

@ -307,15 +307,11 @@ class OAuthController extends BaseController
throw new HttpNotFound('oauth.not-found'); throw new HttpNotFound('oauth.not-found');
} }
$this->session->set( $this->session->set('form-data-username', $userdata->get($config['username']));
'form_data', $this->session->set('form-data-email', $userdata->get($config['email']));
[ $this->session->set('form-data-first_name', $userdata->get($config['first_name']));
'name' => $userdata->get($config['username']), $this->session->set('form-data-last_name', $userdata->get($config['last_name']));
'email' => $userdata->get($config['email']),
'first_name' => $userdata->get($config['first_name']),
'last_name' => $userdata->get($config['last_name']),
],
);
$this->session->set('oauth2_groups', $userdata->get($config['groups'], [])); $this->session->set('oauth2_groups', $userdata->get($config['groups'], []));
$this->session->set('oauth2_connect_provider', $providerName); $this->session->set('oauth2_connect_provider', $providerName);
$this->session->set('oauth2_user_id', $providerUserIdentifier); $this->session->set('oauth2_user_id', $providerUserIdentifier);

View File

@ -459,15 +459,10 @@ class OAuthControllerTest extends TestCase
$this->assertEquals(4242424242, $this->session->get('oauth2_expires_at')->unix()); $this->assertEquals(4242424242, $this->session->get('oauth2_expires_at')->unix());
$this->assertFalse($this->session->get('oauth2_enable_password')); $this->assertFalse($this->session->get('oauth2_enable_password'));
$this->assertEquals(null, $this->session->get('oauth2_allow_registration')); $this->assertEquals(null, $this->session->get('oauth2_allow_registration'));
$this->assertEquals( $this->assertEquals($this->session->get('form-data-username'), 'username');
[ $this->assertEquals($this->session->get('form-data-email'), 'foo.bar@localhost');
'name' => 'username', $this->assertEquals($this->session->get('form-data-first_name'), 'Foo');
'email' => 'foo.bar@localhost', $this->assertEquals($this->session->get('form-data-last_name'), 'Bar');
'first_name' => 'Foo',
'last_name' => 'Bar',
],
$this->session->get('form_data')
);
$this->config->set('registration_enabled', false); $this->config->set('registration_enabled', false);
$this->expectException(HttpNotFound::class); $this->expectException(HttpNotFound::class);
@ -544,12 +539,10 @@ class OAuthControllerTest extends TestCase
$this->setExpects($controller, 'getProvider', ['testprovider'], $provider, $this->atLeastOnce()); $this->setExpects($controller, 'getProvider', ['testprovider'], $provider, $this->atLeastOnce());
$controller->index($request); $controller->index($request);
$this->assertEquals([ $this->assertEquals($this->session->get('form-data-username'), 'testuser');
'email' => 'foo.bar@localhost', $this->assertEquals($this->session->get('form-data-email'), 'foo.bar@localhost');
'name' => 'testuser', $this->assertEquals($this->session->get('form-data-first_name'), 'Test');
'first_name' => 'Test', $this->assertEquals($this->session->get('form-data-last_name'), 'Tester');
'last_name' => 'Tester',
], $this->session->get('form_data'));
} }