mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Reduce IDE errors in App\Http\Controllers\SettingsController
This commit is contained in:
parent
02cdda56e2
commit
5d01a06245
|
@ -14,22 +14,18 @@ use App\Models\Asset;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\FirstAdminNotification;
|
use App\Notifications\FirstAdminNotification;
|
||||||
use App\Notifications\MailTest;
|
use App\Notifications\MailTest;
|
||||||
use Auth;
|
|
||||||
use Crypt;
|
|
||||||
use DB;
|
|
||||||
use enshrined\svgSanitize\Sanitizer;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Image;
|
|
||||||
use Input;
|
|
||||||
use Redirect;
|
use Redirect;
|
||||||
use Response;
|
|
||||||
use App\Http\Requests\SlackSettingsRequest;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This controller handles all actions related to Settings for
|
* This controller handles all actions related to Settings for
|
||||||
|
@ -108,7 +104,7 @@ class SettingsController extends Controller
|
||||||
$start_settings['env_exposed'] = true;
|
$start_settings['env_exposed'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\App::Environment('production') && (true == config('app.debug'))) {
|
if (App::Environment('production') && (true == config('app.debug'))) {
|
||||||
$start_settings['debug_exposed'] = true;
|
$start_settings['debug_exposed'] = true;
|
||||||
} else {
|
} else {
|
||||||
$start_settings['debug_exposed'] = false;
|
$start_settings['debug_exposed'] = false;
|
||||||
|
@ -642,7 +638,7 @@ class SettingsController extends Controller
|
||||||
['next_audit_date' => DB::raw('DATE_ADD(next_audit_date, INTERVAL '.$audit_diff_months.' MONTH)')]
|
['next_audit_date' => DB::raw('DATE_ADD(next_audit_date, INTERVAL '.$audit_diff_months.' MONTH)')]
|
||||||
);
|
);
|
||||||
|
|
||||||
\Log::debug($affected .' assets affected by audit interval update');
|
Log::debug($affected .' assets affected by audit interval update');
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1211,7 +1207,7 @@ class SettingsController extends Controller
|
||||||
Storage::delete($path . '/' . $filename);
|
Storage::delete($path . '/' . $filename);
|
||||||
return redirect()->route('settings.backups.index')->with('success', trans('admin/settings/message.backup.file_deleted'));
|
return redirect()->route('settings.backups.index')->with('success', trans('admin/settings/message.backup.file_deleted'));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Log::debug($e);
|
Log::debug($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1223,7 +1219,7 @@ class SettingsController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hell to the no
|
// Hell to the no
|
||||||
\Log::warning('User ID '.Auth::user()->id.' is attempting to delete backup file '.$filename.' and is not authorized to.');
|
Log::warning('User ID '.Auth::user()->id.' is attempting to delete backup file '.$filename.' and is not authorized to.');
|
||||||
return redirect()->route('settings.backups.index')->with('error', trans('general.backup_delete_not_allowed'));
|
return redirect()->route('settings.backups.index')->with('error', trans('general.backup_delete_not_allowed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1298,7 +1294,7 @@ class SettingsController extends Controller
|
||||||
'--force' => true,
|
'--force' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
\Log::debug('Attempting to restore from: '. storage_path($path).'/'.$filename);
|
Log::debug('Attempting to restore from: '. storage_path($path).'/'.$filename);
|
||||||
|
|
||||||
// run the restore command
|
// run the restore command
|
||||||
Artisan::call('snipeit:restore',
|
Artisan::call('snipeit:restore',
|
||||||
|
@ -1312,26 +1308,26 @@ class SettingsController extends Controller
|
||||||
$output = Artisan::output();
|
$output = Artisan::output();
|
||||||
|
|
||||||
/* Run migrations */
|
/* Run migrations */
|
||||||
\Log::debug('Migrating database...');
|
Log::debug('Migrating database...');
|
||||||
Artisan::call('migrate', ['--force' => true]);
|
Artisan::call('migrate', ['--force' => true]);
|
||||||
$migrate_output = Artisan::output();
|
$migrate_output = Artisan::output();
|
||||||
\Log::debug($migrate_output);
|
Log::debug($migrate_output);
|
||||||
|
|
||||||
$find_user = DB::table('users')->where('username', $user->username)->exists();
|
$find_user = DB::table('users')->where('username', $user->username)->exists();
|
||||||
|
|
||||||
if (!$find_user){
|
if (!$find_user){
|
||||||
\Log::warning('Attempting to restore user: ' . $user->username);
|
Log::warning('Attempting to restore user: ' . $user->username);
|
||||||
$new_user = $user->replicate();
|
$new_user = $user->replicate();
|
||||||
$new_user->push();
|
$new_user->push();
|
||||||
} else {
|
} else {
|
||||||
\Log::debug('User: ' . $user->username .' already exists.');
|
Log::debug('User: ' . $user->username .' already exists.');
|
||||||
}
|
}
|
||||||
|
|
||||||
\Log::debug('Logging all users out..');
|
Log::debug('Logging all users out..');
|
||||||
Artisan::call('snipeit:global-logout', ['--force' => true]);
|
Artisan::call('snipeit:global-logout', ['--force' => true]);
|
||||||
|
|
||||||
DB::table('users')->update(['remember_token' => null]);
|
DB::table('users')->update(['remember_token' => null]);
|
||||||
\Auth::logout();
|
Auth::logout();
|
||||||
|
|
||||||
return redirect()->route('login')->with('success', 'Your system has been restored. Please login again.');
|
return redirect()->route('login')->with('success', 'Your system has been restored. Please login again.');
|
||||||
|
|
||||||
|
@ -1355,7 +1351,7 @@ class SettingsController extends Controller
|
||||||
public function getPurge()
|
public function getPurge()
|
||||||
{
|
{
|
||||||
|
|
||||||
\Log::warning('User '.Auth::user()->username.' (ID'.Auth::user()->id.') is attempting a PURGE');
|
Log::warning('User '.Auth::user()->username.' (ID'.Auth::user()->id.') is attempting a PURGE');
|
||||||
|
|
||||||
if (config('app.allow_purge')=='true') {
|
if (config('app.allow_purge')=='true') {
|
||||||
return view('settings.purge-form');
|
return view('settings.purge-form');
|
||||||
|
@ -1376,16 +1372,16 @@ class SettingsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function postPurge(Request $request)
|
public function postPurge(Request $request)
|
||||||
{
|
{
|
||||||
\Log::warning('User '.Auth::user()->username.' (ID'.Auth::user()->id.') is attempting a PURGE');
|
Log::warning('User '.Auth::user()->username.' (ID'.Auth::user()->id.') is attempting a PURGE');
|
||||||
|
|
||||||
if (config('app.allow_purge')=='true') {
|
if (config('app.allow_purge')=='true') {
|
||||||
\Log::debug('Purging is not allowed via the .env');
|
Log::debug('Purging is not allowed via the .env');
|
||||||
|
|
||||||
if (!config('app.lock_passwords')) {
|
if (!config('app.lock_passwords')) {
|
||||||
|
|
||||||
if ($request->input('confirm_purge')=='DELETE') {
|
if ($request->input('confirm_purge')=='DELETE') {
|
||||||
|
|
||||||
\Log::warning('User ID ' . Auth::user()->id . ' initiated a PURGE!');
|
Log::warning('User ID ' . Auth::user()->id . ' initiated a PURGE!');
|
||||||
// Run a backup immediately before processing
|
// Run a backup immediately before processing
|
||||||
Artisan::call('backup:run');
|
Artisan::call('backup:run');
|
||||||
Artisan::call('snipeit:purge', ['--force' => 'true', '--no-interaction' => true]);
|
Artisan::call('snipeit:purge', ['--force' => 'true', '--no-interaction' => true]);
|
||||||
|
@ -1404,7 +1400,7 @@ class SettingsController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
\Log::error('User '.Auth::user()->username.' (ID'.Auth::user()->id.') is attempting to purge deleted data and is not authorized to.');
|
Log::error('User '.Auth::user()->username.' (ID'.Auth::user()->id.') is attempting to purge deleted data and is not authorized to.');
|
||||||
|
|
||||||
|
|
||||||
// Nope.
|
// Nope.
|
||||||
|
@ -1447,7 +1443,7 @@ class SettingsController extends Controller
|
||||||
])->notify(new MailTest());
|
])->notify(new MailTest());
|
||||||
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', null, 'Maiol sent!'));
|
return response()->json(Helper::formatStandardApiResponse('success', null, 'Maiol sent!'));
|
||||||
} catch (Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', null, $e->getMessage()));
|
return response()->json(Helper::formatStandardApiResponse('success', null, $e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue