Show session summary when pre-auth token exists
This commit is contained in:
@@ -42,6 +42,10 @@
|
|||||||
<p id="authPolicyHintRegister" class="auth-hint"></p>
|
<p id="authPolicyHintRegister" class="auth-hint"></p>
|
||||||
<button id="showLoginButton" type="button">Login</button>
|
<button id="showLoginButton" type="button">Login</button>
|
||||||
</section>
|
</section>
|
||||||
|
<section id="authSessionView" class="auth-panel hidden">
|
||||||
|
<h2>Session</h2>
|
||||||
|
<p id="authSessionText" class="auth-hint"></p>
|
||||||
|
</section>
|
||||||
<div class="controls" id="button-container">
|
<div class="controls" id="button-container">
|
||||||
<button id="connectButton">Connect</button>
|
<button id="connectButton">Connect</button>
|
||||||
<button id="logoutButton" class="hidden">Log out</button>
|
<button id="logoutButton" class="hidden">Log out</button>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Maintainer-controlled web client version.
|
// Maintainer-controlled web client version.
|
||||||
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
||||||
window.CHGRID_WEB_VERSION = "2026.02.25 R248";
|
window.CHGRID_WEB_VERSION = "2026.02.25 R249";
|
||||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||||
|
|||||||
+23
-2
@@ -100,6 +100,8 @@ type Dom = {
|
|||||||
registerPasswordConfirm: HTMLInputElement;
|
registerPasswordConfirm: HTMLInputElement;
|
||||||
registerEmail: HTMLInputElement;
|
registerEmail: HTMLInputElement;
|
||||||
authPolicyHintRegister: HTMLParagraphElement;
|
authPolicyHintRegister: HTMLParagraphElement;
|
||||||
|
authSessionView: HTMLElement;
|
||||||
|
authSessionText: HTMLParagraphElement;
|
||||||
showRegisterButton: HTMLButtonElement;
|
showRegisterButton: HTMLButtonElement;
|
||||||
showLoginButton: HTMLButtonElement;
|
showLoginButton: HTMLButtonElement;
|
||||||
updatesSection: HTMLElement;
|
updatesSection: HTMLElement;
|
||||||
@@ -133,6 +135,8 @@ const dom: Dom = {
|
|||||||
registerPasswordConfirm: requiredById('registerPasswordConfirm'),
|
registerPasswordConfirm: requiredById('registerPasswordConfirm'),
|
||||||
registerEmail: requiredById('registerEmail'),
|
registerEmail: requiredById('registerEmail'),
|
||||||
authPolicyHintRegister: requiredById('authPolicyHintRegister'),
|
authPolicyHintRegister: requiredById('authPolicyHintRegister'),
|
||||||
|
authSessionView: requiredById('authSessionView'),
|
||||||
|
authSessionText: requiredById('authSessionText'),
|
||||||
showRegisterButton: requiredById('showRegisterButton'),
|
showRegisterButton: requiredById('showRegisterButton'),
|
||||||
showLoginButton: requiredById('showLoginButton'),
|
showLoginButton: requiredById('showLoginButton'),
|
||||||
updatesSection: requiredById('updatesSection'),
|
updatesSection: requiredById('updatesSection'),
|
||||||
@@ -587,10 +591,20 @@ function updateConnectAvailability(): void {
|
|||||||
dom.connectButton.disabled = true;
|
dom.connectButton.disabled = true;
|
||||||
dom.loginView.classList.add('hidden');
|
dom.loginView.classList.add('hidden');
|
||||||
dom.registerView.classList.add('hidden');
|
dom.registerView.classList.add('hidden');
|
||||||
|
dom.authSessionView.classList.add('hidden');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (hasSessionToken) {
|
||||||
|
const label = sanitizeAuthUsername(authUsername) || 'current account';
|
||||||
|
dom.authSessionText.textContent = `Logged in as ${label}.`;
|
||||||
|
dom.loginView.classList.add('hidden');
|
||||||
|
dom.registerView.classList.add('hidden');
|
||||||
|
dom.authSessionView.classList.remove('hidden');
|
||||||
|
} else {
|
||||||
dom.loginView.classList.toggle('hidden', authMode !== 'login');
|
dom.loginView.classList.toggle('hidden', authMode !== 'login');
|
||||||
dom.registerView.classList.toggle('hidden', authMode !== 'register');
|
dom.registerView.classList.toggle('hidden', authMode !== 'register');
|
||||||
|
dom.authSessionView.classList.add('hidden');
|
||||||
|
}
|
||||||
const usernameMin = authPolicy?.usernameMinLength ?? 1;
|
const usernameMin = authPolicy?.usernameMinLength ?? 1;
|
||||||
const passwordMin = authPolicy?.passwordMinLength ?? 1;
|
const passwordMin = authPolicy?.passwordMinLength ?? 1;
|
||||||
const hasLoginCredentials =
|
const hasLoginCredentials =
|
||||||
@@ -1115,8 +1129,9 @@ function formatCoordinate(value: number): string {
|
|||||||
/** Persists current local player coordinates for reconnect/refresh restore. */
|
/** Persists current local player coordinates for reconnect/refresh restore. */
|
||||||
function persistPlayerPosition(): void {
|
function persistPlayerPosition(): void {
|
||||||
try {
|
try {
|
||||||
|
const positionKey = getPlayerPositionStorageKey();
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
'spatialChatPosition',
|
positionKey,
|
||||||
JSON.stringify({ x: state.player.x, y: state.player.y }),
|
JSON.stringify({ x: state.player.x, y: state.player.y }),
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
@@ -1126,7 +1141,7 @@ function persistPlayerPosition(): void {
|
|||||||
|
|
||||||
/** Loads previously persisted local player coordinates, when available and valid. */
|
/** Loads previously persisted local player coordinates, when available and valid. */
|
||||||
function getPersistedPlayerPosition(): { x: number; y: number } | null {
|
function getPersistedPlayerPosition(): { x: number; y: number } | null {
|
||||||
const raw = localStorage.getItem('spatialChatPosition');
|
const raw = localStorage.getItem(getPlayerPositionStorageKey());
|
||||||
if (!raw) return null;
|
if (!raw) return null;
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(raw) as { x?: unknown; y?: unknown };
|
const parsed = JSON.parse(raw) as { x?: unknown; y?: unknown };
|
||||||
@@ -1138,6 +1153,12 @@ function getPersistedPlayerPosition(): { x: number; y: number } | null {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Resolves local storage key for per-account saved player position. */
|
||||||
|
function getPlayerPositionStorageKey(): string {
|
||||||
|
const usernameKey = sanitizeAuthUsername(authUsername);
|
||||||
|
return usernameKey ? `spatialChatPosition:${usernameKey}` : 'spatialChatPosition';
|
||||||
|
}
|
||||||
|
|
||||||
/** Picks one random footstep sample URL. */
|
/** Picks one random footstep sample URL. */
|
||||||
function randomFootstepUrl(): string {
|
function randomFootstepUrl(): string {
|
||||||
return FOOTSTEP_SOUND_URLS[Math.floor(Math.random() * FOOTSTEP_SOUND_URLS.length)];
|
return FOOTSTEP_SOUND_URLS[Math.floor(Math.random() * FOOTSTEP_SOUND_URLS.length)];
|
||||||
|
|||||||
@@ -123,6 +123,11 @@ body {
|
|||||||
font-size: 0.92rem;
|
font-size: 0.92rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#authSessionText {
|
||||||
|
margin: 0;
|
||||||
|
color: #cbd5e1;
|
||||||
|
}
|
||||||
|
|
||||||
.nickname-row {
|
.nickname-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user