-
Notifications
You must be signed in to change notification settings - Fork 1
fix: user getting logged out when doing backups or restores #70
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
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.
Pull Request Overview
This PR fixes an issue where users were getting logged out during backup or restore operations by removing unnecessary authentication calls and passing the user instance explicitly through the APIs.
- Updated function signatures in Restorer and Backuper to accept an optional Authenticatable user parameter
- Removed auth()->login calls from job handlers and updated usages to send the user via named parameters
- Changed type hints in controllers and jobs from Statamic\Contracts\Auth\User to Illuminate\Contracts\Auth\Authenticatable
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Restorer.php | Updated restore functions to accept an optional user parameter and removed auth()->user |
| src/Jobs/RestoreJob.php | Removed auth()->login and updated arguments to pass user explicitly |
| src/Jobs/BackupJob.php | Removed auth()->login and updated arguments to pass user explicitly |
| src/Http/Controllers/Api/StoreBackupController.php | Updated type hints and job dispatch arguments for the backup process |
| src/Http/Controllers/Api/RestoreController.php | Updated type hints and job dispatch arguments for the restore process |
| src/Backuper.php | Updated backup method to accept an optional user parameter and removed auth()->user |
| client/src/components/Backup.vue | Commented out debug log in created lifecycle hook |
| * @throws Exception | ||
| */ | ||
| public function restoreFromId(string $id): void | ||
| public function restoreFromId(string $id, ?Authenticatable $user = null): void |
Copilot
AI
May 19, 2025
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.
Consider updating the method's docblock for restoreFromId to document the new optional 'user' parameter for clarity.
| * @throws RestoreFailed | ||
| */ | ||
| public function restore(BackupDto $backup): void | ||
| public function restore(BackupDto $backup, ?Authenticatable $user = null): void |
Copilot
AI
May 19, 2025
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.
Update the restore method's docblock to mention the optional 'user' parameter and describe the change in authentication handling.
| * @throws Exceptions\BackupFailed | ||
| */ | ||
| public function backup(): BackupDto | ||
| public function backup(?Authenticatable $user = null): BackupDto |
Copilot
AI
May 19, 2025
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.
Update the backup method's docblock to include the optional 'user' parameter, reflecting the changes in how the user is passed and used.
I am pretty sure what caused this was that the job ran
auth()->loginand thus invalidated the actual session.