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

+1 -1
View File
@@ -8,7 +8,7 @@ The iOS client is closed source for now. It targets iOS only and uses SwiftUI fo
## Product and user flows to mirror ## Product and user flows to mirror
- **Authentication:** unauthenticated users are sent to sign in. Sign-in accepts email and password; there is no “remember me” option. The current web sign-in page says registration is closed, even though registration endpoints/helpers remain in the backend. Do not expose sign-up unless the web product opens registration. A sign-out API/helper exists, but the current web UI has no visible sign-out or account-management flow; do not invent profile management or account settings. - **Authentication:** unauthenticated users are sent to sign in. Sign-in accepts email and password; the web UI has no “remember me” control. On iOS, request the backend's persistent refresh cookie (`remember: true`) and rely on secure cookie storage to restore sessions across launches; do not expose a remember toggle. The current web sign-in page says registration is closed, even though registration endpoints/helpers remain in the backend. Do not expose sign-up unless the web product opens registration. A sign-out API/helper exists, but the current web UI has no visible sign-out or account-management flow; do not invent profile management or account settings.
- **Home and discovery:** the Home screen presents album carousels grouped by a selection of random genres. Selecting an album opens its detail page. There are no dedicated genre browsing/detail screens in the current web UI. - **Home and discovery:** the Home screen presents album carousels grouped by a selection of random genres. Selecting an album opens its detail page. There are no dedicated genre browsing/detail screens in the current web UI.
- **Search:** the shared navigation search opens Search and updates results as the query changes. Search covers tracks, albums, and artists, with a short debounce; the backend also searches track names and lyric text. Empty search and no-result states show up to nine recently played tracks stored locally in the browser on the web app. Selecting a track plays it; selecting an album or artist opens its detail page. - **Search:** the shared navigation search opens Search and updates results as the query changes. Search covers tracks, albums, and artists, with a short debounce; the backend also searches track names and lyric text. Empty search and no-result states show up to nine recently played tracks stored locally in the browser on the web app. Selecting a track plays it; selecting an album or artist opens its detail page.
- **Catalog pages:** album pages show artwork, title, artists, Play and Shuffle actions, and the album’s tracks. Artist pages show artist artwork/name, Play and Shuffle actions, the artist’s tracks, and albums. A separate artist Songs page lists that artist’s tracks. Tracks link to their album and artist pages. - **Catalog pages:** album pages show artwork, title, artists, Play and Shuffle actions, and the album’s tracks. Artist pages show artist artwork/name, Play and Shuffle actions, the artist’s tracks, and albums. A separate artist Songs page lists that artist’s tracks. Tracks link to their album and artist pages.
+4 -2
View File
@@ -11,9 +11,10 @@ public struct MusicAPI: Sendable {
q([("limit", limit.map(String.init)), ("skip", skip.map(String.init))]) 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( 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 { guard try await sessionStatus().authenticated else {
throw APIError.http( throw APIError.http(
status: 401, message: "The server did not establish an authenticated session.") 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 { nonisolated private struct Credentials: Encodable, Sendable {
let email: String let email: String
let password: String let password: String
let remember: Bool
} }
nonisolated public struct SignOutResponse: Decodable, Sendable { public let success: Bool? } nonisolated public struct SignOutResponse: Decodable, Sendable { public let success: Bool? }