Implement a better management interface for Settings (#809)

This commit is contained in:
Dane Everitt 2017-12-14 21:05:26 -06:00 committed by GitHub
parent 75eb506dab
commit f9df463d32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 1274 additions and 383 deletions

View file

@ -11,7 +11,6 @@ namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Krucas\Settings\Settings;
use Prologue\Alerts\AlertsMessageBag;
class RequireTwoFactorAuthentication
@ -25,11 +24,6 @@ class RequireTwoFactorAuthentication
*/
private $alert;
/**
* @var \Krucas\Settings\Settings
*/
private $settings;
/**
* The names of routes that should be accessable without 2FA enabled.
*
@ -56,12 +50,10 @@ class RequireTwoFactorAuthentication
* RequireTwoFactorAuthentication constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Krucas\Settings\Settings $settings
*/
public function __construct(AlertsMessageBag $alert, Settings $settings)
public function __construct(AlertsMessageBag $alert)
{
$this->alert = $alert;
$this->settings = $settings;
}
/**
@ -81,10 +73,7 @@ class RequireTwoFactorAuthentication
return $next($request);
}
switch ((int) $this->settings->get('2fa', 0)) {
case self::LEVEL_NONE:
return $next($request);
break;
switch ((int) config('pterodactyl.auth.2fa_required')) {
case self::LEVEL_ADMIN:
if (! $request->user()->root_admin || $request->user()->use_totp) {
return $next($request);
@ -95,6 +84,9 @@ class RequireTwoFactorAuthentication
return $next($request);
}
break;
case self::LEVEL_NONE:
default:
return $next($request);
}
$this->alert->danger(trans('auth.2fa_must_be_enabled'))->flash();