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

Implement auto-login feature #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Implement auto-login feature #104

wants to merge 1 commit into from

Conversation

chriszhangusc
Copy link
Collaborator

Check if the current token is valid every time user refreshes the page. If it is, fetch user information and log the user in. If it is not, log the user out and then open the login window.

@chriszhangusc
Copy link
Collaborator Author

Not sure if this is a good way to do it but if anyone has better idea please comment!

@@ -35,7 +35,7 @@ class Dashboard extends React.Component {
}

const mapStateToProps = state => ({
isAuthed: Boolean(state.session.session),
isAuthed: Boolean(state.session.user),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: Just another way to make a truthy or falsy here is using !!state.session.user . But that one is alright too! As I see, it already was there before :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the !!something way, much cleaner.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may use it too often in my own projects and I heard people complaining about it, but I find it the easiest way to transform any JavaScript literal into a boolean.

@rwieruch
Copy link
Owner

LGTM without having tested it. But concise and nice implementation! 👍

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.

None yet

2 participants