Add option to disable UpdateManager after backend login (#4266)
Credit to @Samuell1. Fixes #3471.
This commit is contained in:
parent
84a1df63f2
commit
c21c22e1ba
|
|
@ -93,6 +93,21 @@ return [
|
|||
|
||||
'backendSkin' => 'Backend\Skins\Standard',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Automatically run migrations on login
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If value is true, UpdateMananger will be run on logging in to the backend.
|
||||
| It's recommended to set this value to 'null' in production enviroments
|
||||
| because it clears the cache every time a user logs in to the backend.
|
||||
| If set to null, this setting is enabled when debug mode (app.debug) is enabled
|
||||
| and disabled when debug mode is disabled.
|
||||
|
|
||||
*/
|
||||
|
||||
'runMigrationsOnLogin' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Determines which modules to load
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use System\Classes\UpdateManager;
|
|||
use ApplicationException;
|
||||
use ValidationException;
|
||||
use Exception;
|
||||
use Config;
|
||||
|
||||
/**
|
||||
* Authentication controller
|
||||
|
|
@ -70,8 +71,7 @@ class Auth extends Controller
|
|||
}
|
||||
|
||||
$this->bodyClass .= ' preload';
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
Flash::error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ class Auth extends Controller
|
|||
throw new ValidationException($validation);
|
||||
}
|
||||
|
||||
if (($remember = config('cms.backendForceRemember', true)) === null) {
|
||||
if (is_null($remember = Config::get('cms.backendForceRemember', true))) {
|
||||
$remember = (bool) post('remember');
|
||||
}
|
||||
|
||||
|
|
@ -98,12 +98,17 @@ class Auth extends Controller
|
|||
'password' => post('password')
|
||||
], $remember);
|
||||
|
||||
try {
|
||||
// Load version updates
|
||||
UpdateManager::instance()->update();
|
||||
if (is_null($runMigrationsOnLogin = Config::get('cms.runMigrationsOnLogin', null))) {
|
||||
$runMigrationsOnLogin = Config::get('app.debug', false);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Flash::error($ex->getMessage());
|
||||
|
||||
if ($runMigrationsOnLogin) {
|
||||
try {
|
||||
// Load version updates
|
||||
UpdateManager::instance()->update();
|
||||
} catch (Exception $ex) {
|
||||
Flash::error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Log the sign in event
|
||||
|
|
@ -136,8 +141,7 @@ class Auth extends Controller
|
|||
if (post('postback')) {
|
||||
return $this->restore_onSubmit();
|
||||
}
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
Flash::error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -163,7 +167,7 @@ class Auth extends Controller
|
|||
Flash::success(trans('backend::lang.account.restore_success'));
|
||||
|
||||
$code = $user->getResetPasswordCode();
|
||||
$link = Backend::url('backend/auth/reset/'.$user->id.'/'.$code);
|
||||
$link = Backend::url('backend/auth/reset/' . $user->id . '/' . $code);
|
||||
|
||||
$data = [
|
||||
'name' => $user->full_name,
|
||||
|
|
@ -190,8 +194,7 @@ class Auth extends Controller
|
|||
if (!$userId || !$code) {
|
||||
throw new ApplicationException(trans('backend::lang.account.reset_error'));
|
||||
}
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
Flash::error($ex->getMessage());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue