-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| namespace Itiden\Backup; | ||
|
|
||
| use Exception; | ||
| use Illuminate\Contracts\Auth\Authenticatable; | ||
| use Illuminate\Support\Facades\Artisan; | ||
| use Illuminate\Support\Facades\File; | ||
| use Illuminate\Support\Facades\Pipeline; | ||
|
|
@@ -30,23 +31,23 @@ public function __construct( | |
| * | ||
| * @throws Exception | ||
| */ | ||
| public function restoreFromId(string $id): void | ||
| public function restoreFromId(string $id, ?Authenticatable $user = null): void | ||
|
||
| { | ||
| $backup = $this->repository->find($id); | ||
|
|
||
| if (!$backup) { | ||
| throw new RuntimeException("Backup with id {$id} not found."); | ||
| } | ||
|
|
||
| $this->restore($backup); | ||
| $this->restore($backup, $user); | ||
| } | ||
|
|
||
| /** | ||
| * Restore to the given backup. | ||
| * | ||
| * @throws RestoreFailed | ||
| */ | ||
| public function restore(BackupDto $backup): void | ||
| public function restore(BackupDto $backup, ?Authenticatable $user = null): void | ||
|
||
| { | ||
| $lock = $this->stateManager->getLock(); | ||
|
|
||
|
|
@@ -70,7 +71,6 @@ public function restore(BackupDto $backup): void | |
|
|
||
| event(new BackupRestored($backup)); | ||
|
|
||
| $user = auth()->user(); | ||
| if ($user) { | ||
| $backup->getMetadata()->addRestore($user); | ||
| } | ||
|
|
||
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.