November 2018
Intermediate to advanced
404 pages
10h 16m
English
Open the existing JournalRoutes.swift and add a new line of code to import the Authentication package into the JournalRoutes struct:
import Authentication
Add loginPage related constants to the JournalRoutes struct:
let loginPage = "/journal/login"let loginPageWithError = "/journal/login?error"let loginPageNeedLogin = "/journal/login?login"
Define a new context, LoginContext, to hold the information used in rendering the new template, login.leaf:
struct LoginContext : Encodable { let login: Bool let error: Bool let title: String let author: String}
Group and direct all routes in your web application to the authentication session middleware:
func boot(router: Router) throws { let authSession = Admin.authSessionsMiddleware() ...Read now
Unlock full access