-
-
Notifications
You must be signed in to change notification settings - Fork 142
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
Token and session management #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a pretty quick pass but think this looks good.
const { accessToken } = this.tokens(); | ||
if (accessToken) { | ||
try { | ||
const decodedAccessToken = jwtDecode(accessToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the right way to do this? We're only expiring the token here on the client, correct? This means with a malicious client we can never expire them since we only check the expiration via the client's token.
This is my first time looking at this code, so definitely could be overlooking something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The access token expires by itself over time. The access and refresh tokens are created and stored server side.
// Access token is expired, try to request a new token pair | ||
await this.refreshSession(); | ||
} else { // Access token is still valid, resume the session | ||
this.store.dispatch(setUser(decodedAccessToken.data.user)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we storing all the data locally here?
In general not seeing where data is being sent to the server and retreived. can you point it out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the access token is created the essential user data "id, username, email" are encoded within it and returned to the client. This data is also stored server side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where do we actually send the data to the server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The this.transport.someMethod
calls send data to the server, the transport is a separate package and provided to the Accounts.config in initialization.
No description provided.