Skip to content

Instantly share code, notes, and snippets.

View zhaozzq's full-sized avatar
😜
I may be slow to respond.

Zhao zhaozzq

😜
I may be slow to respond.
View GitHub Profile
@tanner0101
tanner0101 / vapor-4-fluent-authc.swift
Last active May 2, 2024 14:24
Example of authentication with Fluent in Vapor 4
import Fluent
import Vapor
func routes(_ app: Application) throws {
app.post("users") { req -> EventLoopFuture<User> in
try User.Create.validate(req)
let create = try req.content.decode(User.Create.self)
guard create.password == create.confirmPassword else {
throw Abort(.badRequest, reason: "Passwords did not match")
}