在环境文件中增加谷歌验证器开关
This commit is contained in:
@@ -51,6 +51,7 @@ class Index extends Backend
|
||||
'upload' => keys_to_camel_case(get_upload_config($request), ['max_size', 'save_name', 'allowed_suffixes', 'allowed_mime_types', 'forbidden_suffixes']),
|
||||
'cdnUrl' => full_url(),
|
||||
'cdnUrlParams' => config('buildadmin.cdn_url_params'),
|
||||
'totpEnable' => AdminTotp::isEnabled(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
@@ -109,6 +110,13 @@ class Index extends Backend
|
||||
return $this->error($msg ?: __('Incorrect user name or password!'));
|
||||
}
|
||||
|
||||
if (!AdminTotp::isEnabled()) {
|
||||
if (!$this->auth->finalizeLogin((bool) $keep)) {
|
||||
return $this->error($this->auth->getError() ?: __('Login failed'));
|
||||
}
|
||||
return $this->buildLoginSuccessResponse((bool) $keep);
|
||||
}
|
||||
|
||||
if ($this->auth->hasTotpBound()) {
|
||||
$tempToken = AdminTotp::createPendingToken($this->auth->id, AdminTotp::TOKEN_TYPE_VERIFY);
|
||||
return $this->success(__('Please enter Google Authenticator code'), [
|
||||
@@ -127,7 +135,8 @@ class Index extends Backend
|
||||
}
|
||||
|
||||
return $this->success('', [
|
||||
'captcha' => $captchaSwitch
|
||||
'captcha' => $captchaSwitch,
|
||||
'totpEnable' => AdminTotp::isEnabled(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -136,6 +145,10 @@ class Index extends Backend
|
||||
$response = $this->initializeBackend($request);
|
||||
if ($response !== null) return $response;
|
||||
|
||||
if (!AdminTotp::isEnabled()) {
|
||||
return $this->error(__('Google Authenticator is disabled'));
|
||||
}
|
||||
|
||||
if ($request->method() !== 'POST') {
|
||||
return $this->error(__('Method not allowed'), [], 0, ['statusCode' => 405]);
|
||||
}
|
||||
@@ -169,6 +182,10 @@ class Index extends Backend
|
||||
$response = $this->initializeBackend($request);
|
||||
if ($response !== null) return $response;
|
||||
|
||||
if (!AdminTotp::isEnabled()) {
|
||||
return $this->error(__('Google Authenticator is disabled'));
|
||||
}
|
||||
|
||||
if ($request->method() !== 'POST') {
|
||||
return $this->error(__('Method not allowed'), [], 0, ['statusCode' => 405]);
|
||||
}
|
||||
@@ -223,6 +240,10 @@ class Index extends Backend
|
||||
$response = $this->initializeBackend($request);
|
||||
if ($response !== null) return $response;
|
||||
|
||||
if (!AdminTotp::isEnabled()) {
|
||||
return $this->error(__('Google Authenticator is disabled'));
|
||||
}
|
||||
|
||||
if ($request->method() !== 'POST') {
|
||||
return $this->error(__('Method not allowed'), [], 0, ['statusCode' => 405]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user