November 2018
Intermediate to advanced
404 pages
10h 16m
English
Now you need a Model that can be also authenticated by HTTP basic authentication.
Create a new Swift file, Admin.swift, in the /Sources/Application/Model directory.
Subclass the Admin model from Model:
import SwiftKueryORM // [1]struct Admin: Model // [2]{ static var idColumnName = "id" // [4] public static func checkPassword(username: String, password: String) -> Bool { // [5] var ret = false Admin.find(id: username) { user, error in // [6] if let user = user { // [7] if password == user.password { // [8] ret = true } } } return ret } public var id: String // [3] private let password: String}
The new Admin model is constructed in the following steps:
Read now
Unlock full access