Files
vapor-po/Sources/SharedModels/User.swift

96 lines
2.0 KiB
Swift

import Dependencies
import Foundation
public struct User: Codable, Equatable, Identifiable, Sendable {
public var id: UUID
public var email: String
public var username: String
public var createdAt: Date?
public var updatedAt: Date?
public init(
id: UUID,
email: String,
username: String,
createdAt: Date? = nil,
updatedAt: Date? = nil
) {
self.id = id
self.createdAt = createdAt
self.email = email
self.updatedAt = updatedAt
self.username = username
}
}
public extension User {
struct Create: Codable, Sendable {
public let username: String
public let email: String
public let password: String
public let confirmPassword: String
public init(
username: String,
email: String,
password: String,
confirmPassword: String
) {
self.username = username
self.email = email
self.password = password
self.confirmPassword = confirmPassword
}
}
struct Login: Codable, Sendable {
public let username: String?
public let email: String?
public let password: String
public init(
username: String?,
email: String? = nil,
password: String
) {
self.username = username
self.email = email
self.password = password
}
}
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
}
}
struct Update: Codable, Equatable, Sendable {
public let username: String?
public let email: String?
}
}
// public extension User {
// static var mocks: [Self] {
// [
// .init(email: "blob@test.com", username: "blob"),
// .init(email: "blob-jr@test.com", username: "blob-jr"),
// .init(email: "blob-sr@test.com", username: "blob-sr")
// ]
// }
// }