Skip to content

Conversation

@NeoIsRecursive
Copy link
Collaborator

I am pretty sure what caused this was that the job ran auth()->login and thus invalidated the actual session.

@NeoIsRecursive NeoIsRecursive linked an issue May 19, 2025 that may be closed by this pull request
@NeoIsRecursive NeoIsRecursive marked this pull request as ready for review May 19, 2025 09:20
@NeoIsRecursive NeoIsRecursive requested a review from Copilot May 19, 2025 09:20
@NeoIsRecursive NeoIsRecursive merged commit e6ff903 into main May 19, 2025
5 checks passed
@NeoIsRecursive NeoIsRecursive deleted the fix/user-logged-out-while-doing-actions branch May 19, 2025 09:21
Copy link
Contributor

Copilot AI left a 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
Copy link

Copilot AI May 19, 2025

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.

Copilot uses AI. Check for mistakes.
* @throws RestoreFailed
*/
public function restore(BackupDto $backup): void
public function restore(BackupDto $backup, ?Authenticatable $user = null): void
Copy link

Copilot AI May 19, 2025

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.

Copilot uses AI. Check for mistakes.
* @throws Exceptions\BackupFailed
*/
public function backup(): BackupDto
public function backup(?Authenticatable $user = null): BackupDto
Copy link

Copilot AI May 19, 2025

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.

Copilot uses AI. Check for mistakes.
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.

Logout during backup process

2 participants