Adding Registration and Login
To add Registration and Login web pages is as simple as setting up a route in our Routes.swift
and creating a Leaf template file that will render the HTML forms. For our Leaf template, we will need to create a signup form for the new user and a login form for users that have registered already. To get started with adding these forms to our Vapor app, we need to follow these steps:
- First, open the
Routes.swift
file and remove everything inside theĀsetupRoutes
method as we will be setting up two kinds of routes, one for authenticated users and another for unauthenticated. - Next, import the
AuthProvider
andSessions
dependencies that we will need later by adding the following two lines to the top of the file:
import AuthProvider import Sessions
- Next, inside the
setupRoutes
method, add the following two methods that we will define soon:
func setupRoutes() throws { self.setupUnauthenticatedRoutes() self.setupAuthenticatedRoutes() }
- Now, let's define the
setupUnauthenticatedRoutes...