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

Remember me, expired tokens in DB table #228

Closed
frederikhors opened this issue Apr 8, 2019 · 1 comment
Closed

Remember me, expired tokens in DB table #228

frederikhors opened this issue Apr 8, 2019 · 1 comment

Comments

@frederikhors
Copy link
Contributor

Issue opened for the creation of a wiki page that summarizes the doubts and problems for newbies (#210).

I'm trying to use the following model for the "remember me" module.

type AuthToken struct {
	Pid       string `sql:"type:varchar(100)"`
	Token     string
	CreatedAt time.Time `sql:"default:now()"`
}

I'm wondering what to do with tokens in the table DB that are older than the maximum token expiration period.

A simple DELETE ... WHERE created_at > 30 days?

Do you think there is a mistake doing this, @aarondl?

@aarondl
Copy link
Member

aarondl commented Apr 11, 2019

This is fine. Though you need to decide where to do that. Many websites have some sort of cron job system that's running in the background for these sorts of cleanup tasks. You could add it to that, or if you wanted to simplify things you could add the delete where you look up the token, this makes looking up tokens slower, but the cleanup then becomes simplified.

@aarondl aarondl closed this as completed Apr 11, 2019
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

No branches or pull requests

2 participants