Update kitura smtp to fix compile error
This commit is contained in:
parent
76f5e6eb39
commit
2d683e34c4
@ -14,7 +14,7 @@ let package = Package(
|
|||||||
// https://github.com/onevcat/Hedwig
|
// https://github.com/onevcat/Hedwig
|
||||||
// https://github.com/Joannis/SMTPKitten
|
// https://github.com/Joannis/SMTPKitten
|
||||||
// https://github.com/Joannis/VaporSMTPKit <- Uses SMTPKitten
|
// https://github.com/Joannis/VaporSMTPKit <- Uses SMTPKitten
|
||||||
.package(url: "https://github.com/Kitura/Swift-SMTP", from: "5.1.0"),
|
.package(url: "https://github.com/Kitura/Swift-SMTP", from: "6.0.0"),
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
|
@ -71,21 +71,21 @@ final class SQLiteDatabase {
|
|||||||
Possible errors:
|
Possible errors:
|
||||||
- `417`: Player name or email not found.
|
- `417`: Player name or email not found.
|
||||||
*/
|
*/
|
||||||
func sendPasswordResetEmailIfPossible(name: PlayerName, in database: Database) async throws {
|
func sendPasswordResetEmailIfPossible(name: PlayerName, request: Request) async throws {
|
||||||
guard let user = try await User.query(on: database).filter(\.$name == name).first() else {
|
guard let user = try await User.query(on: request.db).filter(\.$name == name).first() else {
|
||||||
throw Abort(.expectationFailed)
|
throw Abort(.expectationFailed)
|
||||||
}
|
}
|
||||||
guard let email = user.recoveryEmail else {
|
guard let email = user.recoveryEmail else {
|
||||||
throw Abort(.expectationFailed)
|
throw Abort(.expectationFailed)
|
||||||
}
|
}
|
||||||
try await user.$resetRequest.load(on: database)
|
try await user.$resetRequest.load(on: request.db)
|
||||||
if let request = user.resetRequest {
|
if let reset = user.resetRequest {
|
||||||
request.renew()
|
reset.renew()
|
||||||
try await request.save(on: database)
|
try await reset.save(on: request.db)
|
||||||
self.sendEmail(name: name, email: email, token: request.resetToken)
|
self.sendEmail(name: name, email: email, token: reset.resetToken)
|
||||||
} else {
|
} else {
|
||||||
let reset = PasswordReset()
|
let reset = PasswordReset()
|
||||||
try await user.$resetRequest.create(reset, on: database)
|
try await user.$resetRequest.create(reset, on: request.db)
|
||||||
self.sendEmail(name: name, email: email, token: reset.resetToken)
|
self.sendEmail(name: name, email: email, token: reset.resetToken)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ func registerPlayer(_ app: Application) {
|
|||||||
func requestPlayerPasswordReset(_ app: Application) {
|
func requestPlayerPasswordReset(_ app: Application) {
|
||||||
app.post("player", "password", "reset") { request async throws -> HTTPResponseStatus in
|
app.post("player", "password", "reset") { request async throws -> HTTPResponseStatus in
|
||||||
let name = try request.header(.name) // Error: 400
|
let name = try request.header(.name) // Error: 400
|
||||||
try await server.sendPasswordResetEmailIfPossible(name: name, in: request.db) // 417
|
try await server.sendPasswordResetEmailIfPossible(name: name, request: request) // 417
|
||||||
return .ok
|
return .ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user