UI: add reconnect + URL password for gateway auth

This commit is contained in:
Palash Oswal
2026-01-07 13:14:40 -05:00
committed by Peter Steinberger
parent b253b9c3a0
commit 765d7771c8
3 changed files with 15 additions and 4 deletions

View File

@@ -247,6 +247,7 @@ export function renderApp(state: AppViewState) {
state.applySettings({ ...state.settings, sessionKey: next });
},
onRefresh: () => state.loadOverview(),
onReconnect: () => state.connect(),
})
: nothing}

View File

@@ -664,11 +664,19 @@ export class ClawdbotApp extends LitElement {
if (!window.location.search) return;
const params = new URLSearchParams(window.location.search);
const token = params.get("token")?.trim();
if (!token) return;
if (!this.settings.token) {
const password = params.get("password")?.trim();
let changed = false;
if (token && !this.settings.token) {
this.applySettings({ ...this.settings, token });
params.delete("token");
changed = true;
}
params.delete("token");
if (password) {
this.password = password;
params.delete("password");
changed = true;
}
if (!changed) return;
const url = new URL(window.location.href);
url.search = params.toString();
window.history.replaceState({}, "", url.toString());

View File

@@ -20,6 +20,7 @@ export type OverviewProps = {
onPasswordChange: (next: string) => void;
onSessionKeyChange: (next: string) => void;
onRefresh: () => void;
onReconnect: () => void;
};
export function renderOverview(props: OverviewProps) {
@@ -84,7 +85,8 @@ export function renderOverview(props: OverviewProps) {
</div>
<div class="row" style="margin-top: 14px;">
<button class="btn" @click=${() => props.onRefresh()}>Refresh</button>
<span class="muted">Reconnect to apply changes.</span>
<button class="btn" @click=${() => props.onReconnect()}>Reconnect</button>
<span class="muted">Reconnect to apply URL/password changes.</span>
</div>
</div>