this->url
in the getJWTSubject method
$this->id
for it to work
Hi, I'm current using the latest commit (dev-develop 821625d).. I'm currently unable to use custom claims. Anyone else have this issue?
$credentials = $request->only(['email', 'password']);
if ($company != '') {
$customClaims = ['context' => ['user' => [ 'email' => $request->email ], 'company' => ['name' => $company]]];
}
try {
if (!$token = JWTAuth::attempt($credentials, $customClaims)) {
throw new UnauthorizedHttpException('Invalid email/password');
}
} catch (JWTException $e) {
return $this->response->errorInternal('Token Generation Error');
}
Authentication works fine and a token is generated however the custom claims are not present within the token.
if ($company != '') {
$customClaims = ['user' => [ 'email' => $request->email ], 'company' => ['name' => $company]];
}
try {
if (!$checkAuth = JWTAuth::attempt($credentials)) {
throw new UnauthorizedHttpException(trans('auth.invalid_credentials'));
} else {
//
$payload = JWTFactory::context($customClaims)->make();
$token = JWTAuth::encode($payload);
}
} catch (JWTException $e) {
return $this->response->errorInternal(trans('auth.token_generation_error'));
}
return $this->response->array(['token' => $token->get()]);