Settings: echtes Profil via /api/auth/me (Rolle, Founder, Abo, Avatar)

Login liefert nur {token, name, is_premium}. Für Admin-/Founder-/Tier-Info
holen wir nach Login (und beim Erscheinen von MainTabView) /api/auth/me und
zeigen ein echtes Profil mit Avatar, Email, Rolle und nur dann Premium-Status,
wenn das relevant ist.
This commit is contained in:
rene 2026-05-30 09:37:12 +02:00
parent 81681130e6
commit bfd327bd40
4 changed files with 126 additions and 3 deletions

View file

@ -7,6 +7,7 @@ final class AuthSession {
var token: String?
var userName: String?
var isPremium: Bool = false
var profile: UserProfile?
var isLoggingIn: Bool = false
var errorMessage: String?
@ -46,5 +47,21 @@ final class AuthSession {
token = nil
userName = nil
isPremium = false
profile = nil
}
/// Fetches the full user profile from /api/auth/me. Called after login and
/// when MainTabView appears, so admin/founder/role info shows up.
func loadProfile() async {
guard token != nil else { return }
do {
let me: UserProfile = try await APIClient.shared.get("/api/auth/me")
self.profile = me
if let premium = me.isPremium {
self.isPremium = premium
}
} catch {
// Profil-Refresh ist non-critical; Settings zeigt sonst nur die Basics.
}
}
}