refactor: extract AUTH_TIMEOUT_MS constant and improve fallback comment accuracy
Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
parent
534e435854
commit
30a502c6fa
|
|
@ -130,6 +130,7 @@
|
||||||
<script>
|
<script>
|
||||||
const DEV_ID_RE = /^EXP-\d{3,}$/;
|
const DEV_ID_RE = /^EXP-\d{3,}$/;
|
||||||
const PROBE_TIMEOUT_MS = 8000;
|
const PROBE_TIMEOUT_MS = 8000;
|
||||||
|
const AUTH_TIMEOUT_MS = 10000;
|
||||||
const API_BASE = getApiBase();
|
const API_BASE = getApiBase();
|
||||||
|
|
||||||
/* ---- State ---- */
|
/* ---- State ---- */
|
||||||
|
|
@ -219,7 +220,7 @@
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var controller = new AbortController();
|
var controller = new AbortController();
|
||||||
var timeoutId = setTimeout(function() { controller.abort(); }, 10000);
|
var timeoutId = setTimeout(function() { controller.abort(); }, AUTH_TIMEOUT_MS);
|
||||||
|
|
||||||
var res = await fetch(API_BASE + '/api/ps/auth/login', {
|
var res = await fetch(API_BASE + '/api/ps/auth/login', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|
@ -250,7 +251,8 @@
|
||||||
showStep('step2');
|
showStep('step2');
|
||||||
document.getElementById('apiKeyInput').focus();
|
document.getElementById('apiKeyInput').focus();
|
||||||
} catch (_err) {
|
} catch (_err) {
|
||||||
// 后端不可达时:使用本地格式验证放行,允许用户继续
|
// 后端不可达时:devId 已通过上方 DEV_ID_RE 格式校验,放行至 API Key 步骤
|
||||||
|
// 真正的安全验证由用户自行提供的 API Key 完成
|
||||||
verifiedDevId = devId;
|
verifiedDevId = devId;
|
||||||
verifiedDevName = devId;
|
verifiedDevName = devId;
|
||||||
sessionStorage.setItem('dev_id', devId);
|
sessionStorage.setItem('dev_id', devId);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue