diff --git a/console-ui/public/portal/index.html b/console-ui/public/portal/index.html
index 2e7f114..febd877 100644
--- a/console-ui/public/portal/index.html
+++ b/console-ui/public/portal/index.html
@@ -200,6 +200,8 @@
+
+
這組帳密就是之後登入知識庫用的,只需要設定這一次。
@@ -680,6 +682,10 @@ function taipeiMonthDay(ms) { var d = new Date(ms + TAIPEI_OFFSET_MS); return {
// 四發全是既有端點,一顆按鈕做完;用戶感受=「建一組帳密就進來了」。
$('fs-submit').addEventListener('click', 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() {
var email = $('fs-email').value.trim();
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 })
.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 || '設定沒有成功,請再試一次');
var ownerTok = x.d.session_token;
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();
})
.catch(function (e) {
+ if (e && e.handled) return; // 409 已自動切登入,不再顯示錯誤
$('fs-submit').disabled = false;
st.textContent = (e && e.message) || friendlyErr(e);
});