feat: Adds reset password api route, needs associated view route.

This commit is contained in:
2025-01-26 21:03:10 -05:00
parent 1f2bb900ca
commit d4a2048b12
5 changed files with 60 additions and 2 deletions

View File

@@ -121,6 +121,7 @@ public extension SiteRoute {
case create(User.Create)
case get(id: User.ID)
case index
case resetPassword(id: User.ID, request: User.ResetPassword)
case update(id: User.ID, updates: User.Update)
static let rootPath = "users"
@@ -143,6 +144,11 @@ public extension SiteRoute {
Path { rootPath }
Method.get
}
Route(.case(Self.resetPassword(id:request:))) {
Path { rootPath; User.ID.parser(); "reset-password" }
Method.patch
Body(.json(User.ResetPassword.self))
}
Route(.case(Self.update(id:updates:))) {
Path { rootPath; User.ID.parser() }
Method.patch

View File

@@ -61,6 +61,19 @@ public extension User {
}
}
struct ResetPassword: Codable, Equatable, Sendable {
public let password: String
public let confirmPassword: String
public init(
password: String,
confirmPassword: String
) {
self.password = password
self.confirmPassword = confirmPassword
}
}
struct Token: Codable, Equatable, Identifiable, Sendable {
public let id: UUID
public let userID: User.ID