Replace 404 errors

This commit is contained in:
Christoph Hagen
2022-10-12 19:43:16 +02:00
parent ff916945df
commit fe429ea7d5
2 changed files with 41 additions and 35 deletions

View File

@ -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
}