OWM-API-Schlüssel explizit über aktive User-ID laden.

Wetter-Abruf nutzt getOwmApiKeyForActiveUser(), damit namespaced Keys nicht am fehlenden active_userid vorbeilaufen.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-31 12:14:43 +02:00
co-authored by Cursor
parent ae89b131a1
commit a6331bea1a
3 changed files with 27 additions and 3 deletions
+6 -1
View File
@@ -35,7 +35,7 @@ function migrateLegacyPrefs(userId: string): void {
}
function resolveUserId(userId?: string | null): string | null {
const id = userId ?? getActiveUserId()
const id = (userId?.trim() || getActiveUserId()?.trim()) || null
if (!id) return null
migrateLegacyPrefs(id)
return id
@@ -75,6 +75,11 @@ export function getOwmApiKey(userId?: string | null): string {
return localStorage.getItem(LEGACY_OWM_KEY) ?? ''
}
/** OWM key for the signed-in user (`active_userid`). Prefer this over a bare `getOwmApiKey()` call. */
export function getOwmApiKeyForActiveUser(): string {
return getOwmApiKey(getActiveUserId())
}
export function setOwmApiKey(userId: string, value: string): void {
migrateLegacyPrefs(userId)
const trimmed = value.trim()