November 2018
Intermediate to advanced
404 pages
10h 16m
English
One of the routes you added previously to the public route is to render a Login page for the user to enter credential information.
Add the showLogin handler for the "login" route:
func showLogin(_ req: Request) throws -> Future<View> { let leaf = try req.make(LeafRenderer.self) var loginError : Bool = false var loginRequired : Bool = false if req.query[Bool.self, at: "error"] != nil { loginError = true } if req.query[Bool.self, at: "login"] != nil { loginRequired = true } let context = LoginContext(login: loginRequired, error: loginError, title: self.title, author: self.author) return leaf.render("login", context)}
The showLogin handler passes a LoginContext instance to render the login.leaf template. It checks for ...
Read now
Unlock full access