You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a "multi-tenant" game application, and instead of having to store the accessed account in the URL, I want it to be part of the JWT token payload. So, a user can login to an account, and that account will be stored as part of the payload.
However, I also want them to be able to switch accounts. This would involve another endpoint, and then I issue the user a new token to be used.
On subsequent requests I would check check the game they've switched to and double-check they can access.
But this saves having to swap domains or have a URL prefix (which I don't want, in this context it doesn't make any sense).
The text was updated successfully, but these errors were encountered:
Add those on User model
//
public function getJWTIdentifier()
{
return $this->getKey();
}
public function getJWTCustomClaims()
{
return $this->jwtCustomClaims;
}
public function setJWTCustomClaims(array $claims)
{
$this->jwtCustomClaims = $claims;
}
//
then u can use setJWTCustomClaims method like that.
//
if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
$user = Auth::user();
$user->setJWTCustomClaims(['test' => 'test']);
$token = JWTAuth::fromUser($user);
I have a "multi-tenant" game application, and instead of having to store the accessed account in the URL, I want it to be part of the JWT token payload. So, a user can login to an account, and that account will be stored as part of the payload.
However, I also want them to be able to switch accounts. This would involve another endpoint, and then I issue the user a new token to be used.
On subsequent requests I would check check the game they've switched to and double-check they can access.
But this saves having to swap domains or have a URL prefix (which I don't want, in this context it doesn't make any sense).
The text was updated successfully, but these errors were encountered: