1
0
Fork 0
mirror of https://github.com/s-frick/effigenix.git synced 2026-03-28 21:29:57 +01:00

fix(cli): Username im Header nach Session-Restore korrekt anzeigen

This commit is contained in:
Sebastian Frick 2026-02-18 12:31:20 +01:00
parent 169f492b76
commit bc0043db93
2 changed files with 27 additions and 4 deletions

View file

@ -12,6 +12,7 @@ interface StoredAuth {
accessToken: string;
refreshToken: string;
expiresAt: string;
username?: string;
}
interface StoredConfig {
@ -59,7 +60,13 @@ export const tokenStorage: TokenProvider = {
async saveTokens(accessToken: string, refreshToken: string, expiresAt: string): Promise<void> {
const config = await loadConfig();
config.auth = { accessToken, refreshToken, expiresAt };
const existing = config.auth;
config.auth = {
accessToken,
refreshToken,
expiresAt,
...(existing?.username !== undefined ? { username: existing.username } : {}),
};
await saveConfig(config);
},
@ -70,6 +77,19 @@ export const tokenStorage: TokenProvider = {
},
};
export async function getStoredUsername(): Promise<string | undefined> {
const config = await loadConfig();
return config.auth?.username;
}
export async function saveUsername(username: string): Promise<void> {
const config = await loadConfig();
if (config.auth) {
config.auth.username = username;
await saveConfig(config);
}
}
export async function getStoredApiBaseUrl(): Promise<string | undefined> {
const config = await loadConfig();
return config.apiBaseUrl;