Skip to content

Commit

Permalink
Add exception throwing on invalid token
Browse files Browse the repository at this point in the history
  • Loading branch information
serdud committed Dec 6, 2022
1 parent 50ac9f3 commit 5fc092b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/InvalidTokenException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Serdud\SocialiteGoogleOneTap;

use Exception;

class InvalidTokenException extends Exception
{
}
6 changes: 5 additions & 1 deletion src/SocialiteGoogleOneTap.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ protected function getTokenUrl()
* @param $token
*
* @return array
* @throws InvalidTokenException
*/
protected function getUserByToken($token): array
{
$client = $this->getClient();
$info = $client->verifyIdToken($token);
if (!$info) {
throw new InvalidTokenException('Invalid token');
}

return $info !== false ? $info : [];
return $info;
}

/**
Expand Down

0 comments on commit 5fc092b

Please sign in to comment.