Add admin role with an admin-only hand range study page
- Optional ADMIN_KEY (6 digits, distinct from ACCESS_KEY): entering it on the key screen signs in as admin (role-specific HMAC cookie; member cookies stay valid). Logged-in members can open /key?admin to enter it. - /range (range chart + color/category quiz, ported from poker-hand and restyled to the site design) and its files under admin/ are served only to admins; everyone else gets 404. Card images cached privately for a day. - Lobby shows a link to the page for admins only (GET /api/me). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1e1ac4e91d
commit
e89d867f85
64 files changed
+477
-19
No files matched your search
@@ -8,6 +8,12 @@
|
||||
const submitBtn = document.getElementById('submit');
|
||||
let busy = false;
|
||||
|
||||
// /key?admin … 入室済みの人が管理者キーを入れるための画面
|
||||
if (new URLSearchParams(location.search).has('admin')) {
|
||||
document.getElementById('key-title').textContent = '管理者キーを入力';
|
||||
document.getElementById('key-hint').textContent = '管理者用の6桁の数字';
|
||||
}
|
||||
|
||||
const value = () => inputs.map((i) => i.value).join('');
|
||||
|
||||
function fill(digits, from) {
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
// 管理者だけにハンドレンジ学習へのリンクを出す(ページ自体もサーバ側で管理者以外は 404)
|
||||
App.api('GET', '/api/me')
|
||||
.then((me) => { document.getElementById('range-link').hidden = !me.admin; })
|
||||
.catch(() => {});
|
||||
|
||||
document.getElementById('create').addEventListener('click', () => {
|
||||
if (requireName()) location.href = '/create';
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user