Skip to content

Commit bc97189

Browse files
committed
Add firebase authentication token to authenticable model
1 parent fe1cde0 commit bc97189

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/FirebaseAuthenticable.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ trait FirebaseAuthenticable
1111
*/
1212
protected $claims;
1313

14+
/**
15+
* Firebase token.
16+
*
17+
* @var string|null
18+
*/
19+
protected $firebaseAuthenticationToken;
20+
1421
/**
1522
* Get User by claim.
1623
*
@@ -79,6 +86,30 @@ public function transformClaims(array $claims): array
7986
return $attributes;
8087
}
8188

89+
/**
90+
* Set firebase token.
91+
*
92+
* @param string $token
93+
*
94+
* @return self
95+
*/
96+
public function setFirebaseAuthenticationToken($token)
97+
{
98+
$this->firebaseAuthenticationToken = $token;
99+
100+
return $this;
101+
}
102+
103+
/**
104+
* Get firebase token.
105+
*
106+
* @return string
107+
*/
108+
public function getFirebaseAuthenticationToken()
109+
{
110+
return $this->firebaseAuthenticationToken;
111+
}
112+
82113
/**
83114
* Get the name of the unique identifier for the user.
84115
*

src/FirebaseGuard.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ public function user(Request $request)
4040
}
4141

4242
try {
43-
$token = $this->verifier->verifyIdToken($token);
43+
$firebaseToken = $this->verifier->verifyIdToken($token);
4444

4545
return app(config('auth.providers.users.model'))
46-
->resolveByClaims($token->getClaims());
46+
->setFirebaseAuthenticationToken($token)
47+
->resolveByClaims($firebaseToken->getClaims());
4748
} catch (\Exception $e) {
4849
if (config('app.debug')) {
4950
throw $e;

0 commit comments

Comments
 (0)