Upgrade to rc5
This commit is contained in:
@@ -340,6 +340,68 @@ class System
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configured UI modes for the login form
|
||||
* with their respective options
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the configuration is invalid
|
||||
* (only in debug mode)
|
||||
*/
|
||||
public function loginMethods(): array
|
||||
{
|
||||
$default = ['password' => []];
|
||||
$methods = A::wrap($this->app->option('auth.methods', $default));
|
||||
|
||||
// normalize the syntax variants
|
||||
$normalized = [];
|
||||
$uses2fa = false;
|
||||
foreach ($methods as $key => $value) {
|
||||
if (is_int($key) === true) {
|
||||
// ['password']
|
||||
$normalized[$value] = [];
|
||||
} elseif ($value === true) {
|
||||
// ['password' => true]
|
||||
$normalized[$key] = [];
|
||||
} else {
|
||||
// ['password' => [...]]
|
||||
$normalized[$key] = $value;
|
||||
|
||||
if (isset($value['2fa']) === true && $value['2fa'] === true) {
|
||||
$uses2fa = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2FA must not be circumvented by code-based modes
|
||||
foreach (['code', 'password-reset'] as $method) {
|
||||
if ($uses2fa === true && isset($normalized[$method]) === true) {
|
||||
unset($normalized[$method]);
|
||||
|
||||
if ($this->app->option('debug') === true) {
|
||||
$message = 'The "' . $method . '" login method cannot be enabled when 2FA is required';
|
||||
throw new InvalidArgumentException($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// only one code-based mode can be active at once
|
||||
if (
|
||||
isset($normalized['code']) === true &&
|
||||
isset($normalized['password-reset']) === true
|
||||
) {
|
||||
unset($normalized['code']);
|
||||
|
||||
if ($this->app->option('debug') === true) {
|
||||
$message = 'The "code" and "password-reset" login methods cannot be enabled together';
|
||||
throw new InvalidArgumentException($message);
|
||||
}
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for an existing mbstring extension
|
||||
*
|
||||
@@ -367,7 +429,9 @@ class System
|
||||
*/
|
||||
public function php(): bool
|
||||
{
|
||||
return version_compare(phpversion(), '7.1.0', '>=');
|
||||
return
|
||||
version_compare(PHP_VERSION, '7.3.0', '>=') === true &&
|
||||
version_compare(PHP_VERSION, '8.1.0', '<') === true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user