feat: add password authentication support (closes #7)
Add token/password auth mode toggle on the login screen.
When password mode is selected, sends { password } instead of
{ token } in the WebSocket connect handshake.
Also adds clipboard utility tests and fixes credential test
to include authMode field.
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
const STORAGE_KEY = 'pinchchat_credentials';
|
||||
|
||||
export function getStoredCredentials(): { url: string; token: string } | null {
|
||||
export type AuthMode = 'token' | 'password';
|
||||
|
||||
export interface StoredCredentials {
|
||||
url: string;
|
||||
token: string;
|
||||
/** Auth mode — defaults to 'token' for backward compatibility */
|
||||
authMode?: AuthMode;
|
||||
}
|
||||
|
||||
export function getStoredCredentials(): StoredCredentials | null {
|
||||
try {
|
||||
const raw = localStorage.getItem(STORAGE_KEY);
|
||||
if (!raw) return null;
|
||||
@@ -12,8 +21,8 @@ export function getStoredCredentials(): { url: string; token: string } | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function storeCredentials(url: string, token: string) {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify({ url, token }));
|
||||
export function storeCredentials(url: string, token: string, authMode: AuthMode = 'token') {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify({ url, token, authMode }));
|
||||
}
|
||||
|
||||
export function clearCredentials() {
|
||||
|
||||
Reference in New Issue
Block a user