Skip to content
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

Merged
merged 6 commits into from
Jan 17, 2017
Merged

Token and session management #34

merged 6 commits into from
Jan 17, 2017

Conversation

TimMikeladze
Copy link
Member

No description provided.

Copy link

@grantga grantga left a 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);
Copy link
Contributor

@BradfordMedeiros BradfordMedeiros Jan 16, 2017

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.

Copy link
Member Author

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));
Copy link
Contributor

@BradfordMedeiros BradfordMedeiros Jan 16, 2017

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?

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

@TimMikeladze TimMikeladze Jan 16, 2017

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.

@TimMikeladze TimMikeladze merged commit 20b1663 into master Jan 17, 2017
Aetherall pushed a commit that referenced this pull request Mar 11, 2018
Aetherall pushed a commit that referenced this pull request Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants