diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 28c56dabff..27fd8236ad 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -1202,11 +1202,10 @@ class SettingsController extends Controller // grab the user's info so we can make sure they exist in the system $user = User::find(Auth::user()->id); + // TODO: run a backup - // TODO: run a backup - - // TODO: add db:wipe + Artisan::call('db:wipe'); // run the restore command Artisan::call('snipeit:restore', @@ -1216,27 +1215,29 @@ class SettingsController extends Controller 'filename' => storage_path($path).'/'.$filename ]); - $output = Artisan::output(); - - // If it's greater than 300, it probably worked + $output = Artisan::output(); if (strlen($output) > 300) { + $find_user = DB::table('users')->where('first_name', $user->first_name)->where('last_name', $user->last_name)->exists(); + if(!$find_user){ + \Log::warning('Attempting to restore user: ' . $user->first_name . ' ' . $user->last_name); + $new_user = $user->replicate(); + $new_user->push(); + } + + $session_files = glob(storage_path("framework/sessions/*")); + foreach ($session_files as $file) { + if (is_file($file)) + unlink($file); + } + DB::table('users')->update(['remember_token' => null]); \Auth::logout(); + return redirect()->route('login')->with('success', 'Your system has been restored. Please login again.'); } else { return redirect()->route('settings.backups.index')->with('error', $output); } - //dd($output); - - // TODO: insert the user if they are not there in the old one - - - - - // log the user out - - } else { return redirect()->route('settings.backups.index')->with('error', trans('admin/settings/message.backup.file_not_found')); diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.php index d5044c3811..f4e8cc57bb 100644 --- a/resources/lang/en/admin/settings/general.php +++ b/resources/lang/en/admin/settings/general.php @@ -32,7 +32,7 @@ return [ 'backups_upload' => 'Upload Backup', 'backups_path' => 'Backups on the server are stored in :path', 'backups_restore_warning' => 'Use the restore button to restore from a previous backup. (This does not currently work with S3 file storage or Docker.

Your entire :app_name database and any uploaded files will be completely replaced by what\'s in the backup file. ', - 'backups_logged_out' => 'You will be logged out once your restore is complete.', + 'backups_logged_out' => 'All existing users, including you, will be logged out once your restore is complete.', 'backups_large' => 'Very large backups may time out on the restore attempt and may still need to be run via command line. ', 'barcode_settings' => 'Barcode Settings', 'confirm_purge' => 'Confirm Purge',