November 2018
Intermediate to advanced
404 pages
10h 16m
English
The login credentials are submitted through the HTTP POST request to the /journal/auth route. You can now implement the code to process the submitted login credentials.
Add the checkLogin handler to process the login credentials:
func checkLogin(_ req: Request) throws -> Future<Response> { return try req.content.decode(Admin.self).flatMap { candidate in return Admin.authenticate(username: candidate.login, password: candidate.password, using: BCryptDigest(), on: req).map { admin in guard let admin = admin else { return req.redirect(to: self.loginPageWithError) } try req.authenticateSession(admin) return req.redirect(to: self.mainPage) } }}
Since Admin implements the passwordAuthenticatable protocol, you can use ...
Read now
Unlock full access