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:
parent
169f492b76
commit
bc0043db93
2 changed files with 27 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue