November 2018
Intermediate to advanced
404 pages
10h 16m
English
The Add New Account feature is based on the addAccount() handler. However, in the addAccount() function, you don't need to handle the authentication and session directly because Vapor handles all of that for you once your model implements the passwordAuthenticatable() and sessionAuthenticatable() protocols.
Add the addAccount() handler:
func addAccount(_ req: Request) throws -> Future<View> { let leaf = try req.make(LeafRenderer.self) let isAdmin = try req.isAuthenticated(Admin.self) let context = CreateContext(isAdmin: isAdmin, title: self.title, author: self.author) return leaf.render("add_account", context)}
The handler renders the add_account.leaf template, which simply provides a form for the authenticated user to ...
Read now
Unlock full access