From f412fc4d4e04bfff0766ded3ec74f28a07cfebcb Mon Sep 17 00:00:00 2001 From: Alessio Date: Sun, 15 Nov 2020 20:58:51 +0100 Subject: [PATCH] Ensure connection do not set registration flag --- src/Auth/ConnectUserIdentity.php | 2 +- tests/Unit/ConnectControllerTest.php | 1 + tests/Unit/RegistrationControllerTest.php | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Auth/ConnectUserIdentity.php b/src/Auth/ConnectUserIdentity.php index 7148ee8..ae65b4f 100644 --- a/src/Auth/ConnectUserIdentity.php +++ b/src/Auth/ConnectUserIdentity.php @@ -91,7 +91,7 @@ protected function createIdentity($user, $provider, $oauthUser) 'token'=> IdentityCrypt::encryptString($oauthUser->token), 'refresh_token'=> IdentityCrypt::encryptString($oauthUser->refreshToken), 'expires_at'=> $oauthUser->expiresIn ? now()->addSeconds($oauthUser->expiresIn) : null, - 'registration' => true, + 'registration' => false, ] ); } diff --git a/tests/Unit/ConnectControllerTest.php b/tests/Unit/ConnectControllerTest.php index 9e9e4d1..358f033 100644 --- a/tests/Unit/ConnectControllerTest.php +++ b/tests/Unit/ConnectControllerTest.php @@ -103,6 +103,7 @@ public function test_connect_creates_identity() $this->assertEquals(Carbon::create(2020, 11, 12, 10, 21), $updatedIdentity->expires_at); $this->assertEquals('T2', IdentityCrypt::decryptString($updatedIdentity->token)); $this->assertEquals('RT2', IdentityCrypt::decryptString($updatedIdentity->refresh_token)); + $this->assertFalse($updatedIdentity->registration); } public function test_connect_updates_existing_identity() diff --git a/tests/Unit/RegistrationControllerTest.php b/tests/Unit/RegistrationControllerTest.php index c6021a9..94137c9 100644 --- a/tests/Unit/RegistrationControllerTest.php +++ b/tests/Unit/RegistrationControllerTest.php @@ -72,6 +72,7 @@ public function test_user_can_be_registered() $this->assertEquals(IdentityCrypt::hash('U1'), $firstIdentity->provider_id); $this->assertEquals('gitlab', $firstIdentity->provider); $this->assertNotNull($firstIdentity->token); + $this->assertTrue($firstIdentity->registration); } public function test_user_cannot_register_twice()