Replace 404 errors
This commit is contained in:
@ -59,14 +59,14 @@ final class SQLiteDatabase {
|
||||
Send a password reset email.
|
||||
|
||||
Possible errors:
|
||||
- `404`: Player name or email not found.
|
||||
- `417`: Player name or email not found.
|
||||
*/
|
||||
func sendPasswordResetEmailIfPossible(name: PlayerName, in database: Database) async throws {
|
||||
guard let user = try await User.query(on: database).filter(\.$name == name).first() else {
|
||||
throw Abort(.notFound)
|
||||
throw Abort(.expectationFailed)
|
||||
}
|
||||
guard let email = user.recoveryEmail else {
|
||||
throw Abort(.notFound)
|
||||
throw Abort(.expectationFailed)
|
||||
}
|
||||
try await user.$resetRequest.load(on: database)
|
||||
if let request = user.resetRequest {
|
||||
@ -115,7 +115,7 @@ final class SQLiteDatabase {
|
||||
Change the password of a user with a recovery token
|
||||
|
||||
Possible errors:
|
||||
- `404`: Reset token not found or expired
|
||||
- `417`: Reset token not found or expired
|
||||
*/
|
||||
func updatePassword(password: String, forResetToken token: String, in database: Database) async throws {
|
||||
// 1. Find and validate the reset request
|
||||
@ -146,7 +146,7 @@ final class SQLiteDatabase {
|
||||
.query(on: database)
|
||||
.filter(\.$name == name)
|
||||
.first()
|
||||
.unwrap(or: Abort(.notFound))
|
||||
.unwrap(or: Abort(.unauthorized))
|
||||
.passwordHash
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user