November 2018
Intermediate to advanced
404 pages
10h 16m
English
For the TypeSafe HTTP Basic Authentication method, you can add the TypeSafeHTTPBasic protocol to the Admin model:
public struct Admin: TypeSafeHTTPBasic, Model { static var idColumnName = "id" // [1] public var id: String var name: String var login: String var password: String // [2] public static func verifyPassword(login: String, // [3] password: String, callback: @escaping (Admin?) -> Void) { Admin.find(id: login) { admin, error in // [4] if let admin = admin { if password == admin.password { // [5] callback(admin) // [6] return } } callback(nil) // [7] } }}
Here are some important points to note:
Read now
Unlock full access