- Refactor authentication flow to require endpoint for login and decouple token saving - Add and integrate search functionality for bookmarks - Simplify and improve server settings setup (remove connection test, direct save & login) - Update sidebar/tab navigation to include search and improve structure - Show placeholder image in BookmarkCardView if no image is available, ensuring consistent layout - Improve BookmarkDetailView header and meta info display - Add utility for domain extraction from URLs - General code cleanup and minor UI/UX improvements
31 lines
889 B
Swift
31 lines
889 B
Swift
import Foundation
|
|
|
|
class AuthRepository: PAuthRepository {
|
|
private let api: PAPI
|
|
private let settingsRepository: PSettingsRepository
|
|
|
|
init(api: PAPI, settingsRepository: PSettingsRepository) {
|
|
self.api = api
|
|
self.settingsRepository = settingsRepository
|
|
}
|
|
|
|
func login(endpoint: String, username: String, password: String) async throws -> User {
|
|
let userDto = try await api.login(endpoint: endpoint, username: username, password: password)
|
|
// Token wird automatisch von der API gespeichert
|
|
return User(id: userDto.id, token: userDto.token)
|
|
}
|
|
|
|
func logout() async throws {
|
|
await api.tokenProvider.clearToken()
|
|
}
|
|
|
|
func getCurrentSettings() async throws -> Settings? {
|
|
return try await settingsRepository.loadSettings()
|
|
}
|
|
}
|
|
|
|
struct User {
|
|
let id: String
|
|
let token: String
|
|
}
|