80 lines
1.6 KiB
Swift
80 lines
1.6 KiB
Swift
import Dependencies
|
|
import Foundation
|
|
|
|
// FIX: Remove username.
|
|
public struct User: Codable, Equatable, Identifiable, Sendable {
|
|
|
|
public let id: UUID
|
|
public let email: String
|
|
public let createdAt: Date
|
|
public let updatedAt: Date
|
|
|
|
public init(
|
|
id: UUID,
|
|
email: String,
|
|
createdAt: Date,
|
|
updatedAt: Date
|
|
) {
|
|
self.id = id
|
|
self.email = email
|
|
self.createdAt = createdAt
|
|
self.updatedAt = updatedAt
|
|
}
|
|
}
|
|
|
|
extension User {
|
|
public struct Create: Codable, Equatable, Sendable {
|
|
|
|
public let email: String
|
|
public let password: String
|
|
public let confirmPassword: String
|
|
|
|
public init(
|
|
email: String,
|
|
password: String,
|
|
confirmPassword: String
|
|
) {
|
|
self.email = email
|
|
self.password = password
|
|
self.confirmPassword = confirmPassword
|
|
}
|
|
}
|
|
|
|
public struct Login: Codable, Equatable, Sendable {
|
|
public let email: String
|
|
public let password: String
|
|
public let next: String?
|
|
|
|
public init(email: String, password: String, next: String? = nil) {
|
|
self.email = email
|
|
self.password = password
|
|
self.next = next
|
|
}
|
|
}
|
|
|
|
public struct Token: Codable, Equatable, Identifiable, Sendable {
|
|
|
|
public let id: UUID
|
|
public let userID: User.ID
|
|
public let value: String
|
|
|
|
public init(id: UUID, userID: User.ID, value: String) {
|
|
self.id = id
|
|
self.userID = userID
|
|
self.value = value
|
|
}
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
|
|
extension User {
|
|
public static var mock: Self {
|
|
@Dependency(\.uuid) var uuid
|
|
@Dependency(\.date.now) var now
|
|
return .init(id: uuid(), email: "testy@example.com", createdAt: now, updatedAt: now)
|
|
}
|
|
}
|
|
|
|
#endif
|