mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 09:37:50 -05:00
fix(staff): a Discord sign-in asks for the 2FA code, and the bot needs one too
Since7dee290a Discord account linked to a staff member opened the moderator panel for 12 hours on Discord's word alone, with no password and no 2FA code, though the normal sign-in asks for both every time; and sinceb11ae1dthe bot took /moderate and /burrow commands from that Discord account alone. The link outlives a new password and "sign out everywhere", so a taken-over Discord account was enough to act as the staff member. The admin dashboard's Discord sign-in (adminDashboardAccess) skipped its password the same way. - /mod/discord/callback and /admin/discord/callback no longer sign in: they keep a pending sign-in for 5 minutes (a Strict cookie) and the page asks for the linked account's 2FA code (POST .../api/discord/code). Five wrong codes and it must start again at Discord. The admin one also needs the account to have 2FA on and not be locked. - the bot's commands and buttons count only for a staff member with a panel session that took a code (modpanel.discordBot.commandActor): the password sign-in, or Discord and a code; not the game's token sign-in. A new password, signing out everywhere or 2FA turned off end those sessions (forget), and so the bot's use. Whose Discord it is still keeps linked staff out of /discord moderation, and lets them close tickets. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
83c2fc3b0b
commit
3b53c8dab8
5 files changed
+278
-25
No files matched your search
+44
-1
@@ -454,6 +454,12 @@
|
||||
<div id="captcha"></div>
|
||||
<button class="primary" id="gate-button">Sign in</button>
|
||||
</form>
|
||||
<form id="discord-code-form" hidden>
|
||||
<p class="hint">Discord confirmed who you are. Enter your 2FA code to finish signing in.</p>
|
||||
<label for="discord-code">2FA code</label>
|
||||
<input id="discord-code" inputmode="numeric" autocomplete="one-time-code" maxlength="20" spellcheck="false" required>
|
||||
<button class="primary" id="discord-code-button">Finish signing in</button>
|
||||
</form>
|
||||
<button type="button" id="discord-sign-in" hidden>Sign in with Discord</button>
|
||||
<p class="hint" id="discord-gate-hint" hidden>Use the Discord account linked to your active staff account.</p>
|
||||
<p class="status" id="gate-status" role="status"></p>
|
||||
@@ -3195,6 +3201,38 @@
|
||||
location.href = "/dashboard/staff/discord/login";
|
||||
});
|
||||
|
||||
// after Discord: the 2FA code, which opens the panel (POST discord/code)
|
||||
const showDiscordCode = message => {
|
||||
showGate(message);
|
||||
$("gate-form").hidden = true;
|
||||
$("discord-code-form").hidden = false;
|
||||
$("discord-sign-in").textContent = "Start again with Discord";
|
||||
$("discord-code").focus();
|
||||
};
|
||||
|
||||
$("discord-code-form").addEventListener("submit", async event => {
|
||||
event.preventDefault();
|
||||
$("discord-code-button").disabled = true;
|
||||
const result = await api("discord/code", {code: $("discord-code").value.trim()});
|
||||
$("discord-code-button").disabled = false;
|
||||
$("discord-code").value = "";
|
||||
if (result.ok) {
|
||||
history.replaceState(null, "", location.pathname + location.hash);
|
||||
$("discord-code-form").hidden = true;
|
||||
$("gate-form").hidden = false;
|
||||
showPanel(result.data.username);
|
||||
}
|
||||
else if (result.data.expired) {
|
||||
history.replaceState(null, "", location.pathname + location.hash);
|
||||
$("discord-code-form").hidden = true;
|
||||
$("gate-form").hidden = false;
|
||||
showGate(said(result));
|
||||
}
|
||||
else {
|
||||
setStatus($("gate-status"), said(result), true);
|
||||
}
|
||||
});
|
||||
|
||||
$("sign-out").addEventListener("click", async () => {
|
||||
await api("logout", {});
|
||||
showGate("");
|
||||
@@ -3215,7 +3253,12 @@
|
||||
discord: "Discord could not confirm that sign-in. Try again.",
|
||||
off: "Discord sign-in is not configured.",
|
||||
}[discordResult] || "";
|
||||
showGate(result.status === 0 ? result.data.error : discordMessage);
|
||||
if (discordResult === "code" && result.status !== 0) {
|
||||
showDiscordCode("");
|
||||
}
|
||||
else {
|
||||
showGate(result.status === 0 ? result.data.error : discordMessage);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user