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');
}
$this->session->set(
'form_data',
[
'name' => $userdata->get($config['username']),
'email' => $userdata->get($config['email']),
'first_name' => $userdata->get($config['first_name']),
'last_name' => $userdata->get($config['last_name']),
],
);
$this->session->set('form-data-username', $userdata->get($config['username']));
$this->session->set('form-data-email', $userdata->get($config['email']));
$this->session->set('form-data-first_name', $userdata->get($config['first_name']));
$this->session->set('form-data-last_name', $userdata->get($config['last_name']));
$this->session->set('oauth2_groups', $userdata->get($config['groups'], []));
$this->session->set('oauth2_connect_provider', $providerName);
$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->assertFalse($this->session->get('oauth2_enable_password'));
$this->assertEquals(null, $this->session->get('oauth2_allow_registration'));
$this->assertEquals(
[
'name' => 'username',
'email' => 'foo.bar@localhost',
'first_name' => 'Foo',
'last_name' => 'Bar',
],
$this->session->get('form_data')
);
$this->assertEquals($this->session->get('form-data-username'), 'username');
$this->assertEquals($this->session->get('form-data-email'), 'foo.bar@localhost');
$this->assertEquals($this->session->get('form-data-first_name'), 'Foo');
$this->assertEquals($this->session->get('form-data-last_name'), 'Bar');
$this->config->set('registration_enabled', false);
$this->expectException(HttpNotFound::class);
@ -544,12 +539,10 @@ class OAuthControllerTest extends TestCase
$this->setExpects($controller, 'getProvider', ['testprovider'], $provider, $this->atLeastOnce());
$controller->index($request);
$this->assertEquals([
'email' => 'foo.bar@localhost',
'name' => 'testuser',
'first_name' => 'Test',
'last_name' => 'Tester',
], $this->session->get('form_data'));
$this->assertEquals($this->session->get('form-data-username'), 'testuser');
$this->assertEquals($this->session->get('form-data-email'), 'foo.bar@localhost');
$this->assertEquals($this->session->get('form-data-first_name'), 'Test');
$this->assertEquals($this->session->get('form-data-last_name'), 'Tester');
}