Open paulhobbel opened 8 years ago
Please provide a documentation. I am using it, but I dont know how to used it. I am stacked on a part where in loggedIn() function and it gives me this error
A JWT Token must have 3 parts!
The server which I am using is Loopback framework and it returns it own Token. the loopback token looks like this
Ff5qyulO193bGy7f90USTUT8J2Mwce8YfalDFbhDjwa99zK3Ukx2YGnSIIfDOGjB
Yea I need to work on the documentation, this module currently only works with jwt tokens. Could you tell me a little bit more about Loopback?
Loopback is a Node.js API framework which is build base and expressjs framework.loopback.io. The documentation for authentication is : user login.
By default loopback return Ff5qyulO193bGy7f90USTUT8J2Mwce8YfalDFbhDjwa99zK3Ukx2YGnSIIfDOGjB
, but what I did is that added express-jwt
to loopback and return a JWT token.
Also, isExpired() function does not work correctly, it take 1970-01-01 00:00:00 + timeout
Oh that shouldn't happen, will take a look into that later today
Are you sure the exp key in your token is set correctly
Yes, I think I found the problem. There is problem with getExpirationDate
function. inside of this function you have let date = new Date(0);
which returns 1970-01-01T00:00:00.000Z
.
I think its wrong. It should get iat
property of JWT which is issue at.
The function should look like
public getExpirationDate(): any { let decoded = this.decodeToken(); if(!decoded.hasOwnProperty('exp') && !decoded.hasOwnProperty('iat')) { return new Date(); } let issueAt = decoded.iat let date = new Date(issueAt*1000); date.setUTCSeconds(decoded.exp); return date; }
Oh yea, indeed can you make a pull request
I will
@nimatullah actually my way was correct. The exp is a timestamp, this starts counting from 1970-01-01T00:00:00.000Z
. My way is a bit weird indeed, but it does work
Make a doc for this library so people know how to use it. Atleast show how to set it up...