diff --git a/app/Services/UserTokenService.php b/app/Services/UserTokenService.php index 45e9e50a0..eff545a91 100644 --- a/app/Services/UserTokenService.php +++ b/app/Services/UserTokenService.php @@ -10,8 +10,7 @@ class UserTokenService { /** - * Creates an access token for the given user and revokes - * any existing. + * Creates an access token for the given user. * * @param integer $userCid * @throws ModelNotFoundException @@ -21,13 +20,6 @@ public function create(int $userCid) : string { $user = User::findOrFail($userCid); - // Revoke existing tokens - if ($user->tokens) { - foreach ($user->tokens as $token) { - $token->revoke(); - } - } - return $user->createToken('access', [AuthServiceProvider::SCOPE_USER])->accessToken; } diff --git a/tests/app/Services/UserTokenServiceTest.php b/tests/app/Services/UserTokenServiceTest.php index f6b85b495..8aa2c42c1 100644 --- a/tests/app/Services/UserTokenServiceTest.php +++ b/tests/app/Services/UserTokenServiceTest.php @@ -36,14 +36,14 @@ public function testItThrowsAnExceptionIfUserNotFound() $this->service->create(999); } - public function testItOnlyAllowsOneActiveToken() + public function testItOnlyAllowsMultipleActiveTokens() { $this->service->create(1203533); $this->service->create(1203533); $this->service->create(1203533); $this->service->create(1203533); - $this->assertEquals(1, Token::where('user_id', 1203533)->where('revoked', false)->get()->count()); + $this->assertEquals(4, Token::where('user_id', 1203533)->where('revoked', false)->get()->count()); } public function testItCreatesAUserToken()