-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom claim not working as expected #1388
Comments
I added the claims through User model. |
I'm having the same issue, I need different types of tokens, with custom exp dates. Adding hte claims through User model is not a solution |
@tymondesigns |
See here for v1.0.0 http://jwt-auth.readthedocs.io/en/develop/auth-guard/#adding-custom-claims |
Still not working with LUMEN. $token = app('auth')->attempt($credentials) Always return false. |
Just to clarify: $credentials = $request->only('email', 'password'); $valid is true. $test = JWTAuth::attempt($credentials); $test is false. So there is something with attempt. |
Hello,
based on documentation, the following code is supposed to work:
$credentials = $request->only('email', 'password'); $customClaims = ['sCustomercode' => '1234', 'sActivesessionID' => 'abcd']; if (!$token = app('auth')->guard($this->guard)->attempt($credentials, $customClaims)) { return response()->json(['error' => 'invalid_credentials'], 401); }
but when token is decoded, I have no custom properties.
The only way for now is:
$token = JWTAuth::fromUser($user, $customClaims); $payload = JWTFactory::sCustomercode('1234')->sActivesessionID('1234')->sVerification('abcd')->make(); $token = JWTAuth::encode($payload)->get();
It is more intuitive to provide an array in attempt(), is it a bug or the feature changed without refreshing the documentation?
Thanks.
The text was updated successfully, but these errors were encountered: