fix(portal/t49): 首登頁補逃生口——『已經有帳號?改用登入』+setup 409 自動切登入帶提示(leo 實撞死路)
This commit is contained in:
@@ -200,6 +200,8 @@
|
|||||||
<input type="password" id="fs-password2" class="txt" placeholder="再輸入一次密碼" autocomplete="new-password" style="padding:15px 16px;font-size:17px;border-radius:11px">
|
<input type="password" id="fs-password2" class="txt" placeholder="再輸入一次密碼" autocomplete="new-password" style="padding:15px 16px;font-size:17px;border-radius:11px">
|
||||||
<button class="btn" id="fs-submit" style="margin-top:6px;padding:15px;font-size:17px;letter-spacing:.12em">建立帳號並進入</button>
|
<button class="btn" id="fs-submit" style="margin-top:6px;padding:15px;font-size:17px;letter-spacing:.12em">建立帳號並進入</button>
|
||||||
<div id="fs-status" class="err" style="font-size:14px;min-height:1.2em"></div>
|
<div id="fs-status" class="err" style="font-size:14px;min-height:1.2em"></div>
|
||||||
|
<!-- leo 07-25 實撞:已設定過(409)時這頁是死路——必須有回登入的路 -->
|
||||||
|
<button class="btn3" id="fs-tologin" style="padding:9px 16px;font-size:14px;border-radius:999px;align-self:center;cursor:pointer">已經有帳號?改用登入</button>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size:13.5px;color:rgba(var(--ink-rgb),.4);line-height:1.7">這組帳密就是之後登入知識庫用的,只需要設定這一次。</div>
|
<div style="font-size:13.5px;color:rgba(var(--ink-rgb),.4);line-height:1.7">這組帳密就是之後登入知識庫用的,只需要設定這一次。</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -680,6 +682,10 @@ function taipeiMonthDay(ms) { var d = new Date(ms + TAIPEI_OFFSET_MS); return {
|
|||||||
// 四發全是既有端點,一顆按鈕做完;用戶感受=「建一組帳密就進來了」。
|
// 四發全是既有端點,一顆按鈕做完;用戶感受=「建一組帳密就進來了」。
|
||||||
$('fs-submit').addEventListener('click', doFirstSetup);
|
$('fs-submit').addEventListener('click', doFirstSetup);
|
||||||
$('fs-password2').addEventListener('keydown', function (ev) { if (ev.key === 'Enter') doFirstSetup(); });
|
$('fs-password2').addEventListener('keydown', function (ev) { if (ev.key === 'Enter') doFirstSetup(); });
|
||||||
|
$('fs-tologin').addEventListener('click', function () {
|
||||||
|
$('v-firstsetup').classList.remove('on');
|
||||||
|
$('v-login').classList.add('on');
|
||||||
|
});
|
||||||
function doFirstSetup() {
|
function doFirstSetup() {
|
||||||
var email = $('fs-email').value.trim();
|
var email = $('fs-email').value.trim();
|
||||||
var pw = $('fs-password').value;
|
var pw = $('fs-password').value;
|
||||||
@@ -696,6 +702,15 @@ function taipeiMonthDay(ms) { var d = new Date(ms + TAIPEI_OFFSET_MS); return {
|
|||||||
};
|
};
|
||||||
post('/console/setup', { email: email, password: pw })
|
post('/console/setup', { email: email, password: pw })
|
||||||
.then(function (x) {
|
.then(function (x) {
|
||||||
|
// 已設定過(409)=這實例其實有人建過了——自動帶去登入,別把用戶困在死路(leo 實撞)
|
||||||
|
if (x.status === 409) {
|
||||||
|
$('fs-submit').disabled = false;
|
||||||
|
$('v-firstsetup').classList.remove('on');
|
||||||
|
$('v-login').classList.add('on');
|
||||||
|
$('login-email').value = email;
|
||||||
|
$('login-status').textContent = '這個知識庫已經設定過帳號了,直接登入即可。';
|
||||||
|
throw { handled: true };
|
||||||
|
}
|
||||||
if (!x.ok || !x.d.session_token) throw new Error(x.d.error || '設定沒有成功,請再試一次');
|
if (!x.ok || !x.d.session_token) throw new Error(x.d.error || '設定沒有成功,請再試一次');
|
||||||
var ownerTok = x.d.session_token;
|
var ownerTok = x.d.session_token;
|
||||||
return post('/portal/admin/bootstrap', { email: email, password: pw, display_name: email.split('@')[0] }, { Authorization: 'Bearer ' + ownerTok })
|
return post('/portal/admin/bootstrap', { email: email, password: pw, display_name: email.split('@')[0] }, { Authorization: 'Bearer ' + ownerTok })
|
||||||
@@ -724,6 +739,7 @@ function taipeiMonthDay(ms) { var d = new Date(ms + TAIPEI_OFFSET_MS); return {
|
|||||||
boot();
|
boot();
|
||||||
})
|
})
|
||||||
.catch(function (e) {
|
.catch(function (e) {
|
||||||
|
if (e && e.handled) return; // 409 已自動切登入,不再顯示錯誤
|
||||||
$('fs-submit').disabled = false;
|
$('fs-submit').disabled = false;
|
||||||
st.textContent = (e && e.message) || friendlyErr(e);
|
st.textContent = (e && e.message) || friendlyErr(e);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user