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

Delete user tokens when user is deleted #406

Merged
merged 2 commits into from
Oct 28, 2020
Merged

Delete user tokens when user is deleted #406

merged 2 commits into from
Oct 28, 2020

Conversation

lostdesign
Copy link
Contributor

@lostdesign lostdesign commented Oct 27, 2020

Currently if a user is deleted, their api tokens will remain inside the database. The api tokens are now deleted at the same time the user will be deleted.

delete a users token once user is deleted
@taylorotwell
Copy link
Member

I wonder if this would be better implemented as a cascading delete foreign key constraint?

@lostdesign
Copy link
Contributor Author

lostdesign commented Oct 27, 2020

Yeah, I guess cascade would be the better option here to be fair. I should also run tests locally before pushing 🤦‍♂️ Should I change to cascade?

@taylorotwell
Copy link
Member

That's how I would personally do it.

@lostdesign
Copy link
Contributor Author

That'd mean the change has to be done in the laravel/sanctum migration? As jetstream uses sanctum for this and the migration is there.

@taylorotwell
Copy link
Member

Ick. It's morphable too. Your PR may be the best approach.

@taylorotwell taylorotwell merged commit 382181b into laravel:1.x Oct 28, 2020
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.

2 participants