Persist native sign-in sessions

This commit is contained in:
lucast committed 2026-10-07 02:06:32 +02:00
1 parent 39a64bebf2
commit 1e6bb30b50
2 files changed
+5 -3

No files matched your search

+4 -2
View File
@@ -11,9 +11,10 @@ public struct MusicAPI: Sendable {
q([("limit", limit.map(String.init)), ("skip", skip.map(String.init))])
}
public func signIn(email: String, password: String) async throws {
public func signIn(email: String, password: String, remember: Bool = true) async throws {
let _: APIClient.EmptyResponse = try await client.request(
"POST", path: "auth/signin", body: Credentials(email: email, password: password))
"POST", path: "auth/signin",
body: Credentials(email: email, password: password, remember: remember))
guard try await sessionStatus().authenticated else {
throw APIError.http(
status: 401, message: "The server did not establish an authenticated session.")
@@ -123,5 +124,6 @@ public struct MusicAPI: Sendable {
nonisolated private struct Credentials: Encodable, Sendable {
let email: String
let password: String
let remember: Bool
}
nonisolated public struct SignOutResponse: Decodable, Sendable { public let success: Bool? }