November 2018
Intermediate to advanced
404 pages
10h 16m
English
Now, you're ready to specify the routes that require secured access. To do that, use RedirectMiddleware to reroute any unauthenticated access requests to the login template.
Add secureRouter in JournalRoutes.swift, right after the group of public routes:
let securedRouter = authRouter.grouped(RedirectMiddleware<Admin>(path: "/journal/login"))
You can build onto secureRouter to specify all protected routes.
Add the following HTTP GET and POST requests to securedRouter:
// protected routes: entrieslet adminRouter = securedRouter.grouped("journal/admin")adminRouter.get("create", use: createEntry)adminRouter.post("new", use: newEntry)adminRouter.get(Int.parameter, "get", use: getEntry)adminRouter.post(Int.parameter, ...Read now
Unlock full access