November 2018
Intermediate to advanced
404 pages
10h 16m
English
While AuthenticationProvider allows you to authenticate a user, you'll also need to set up SessionMiddleware in Vapor in order to maintain the user's sessions.
Add the following code before services.register(middlewares) in configure.swift:
middlewares.use(SessionsMiddleware.self)
The session middleware by default uses in-memory storage for session information. In future Vapor releases, Vapor may add support for Fluent databases, such as SQLite, PostgreSQL, and MySQL, or cache service, such as Redis, to store the session information.
If you want to use key-value storage for sessions, configure your middleware's preference to be the KeyedCache service that is supported in Vapor:
config.prefer(MemoryKeyedCache.self, ...
Read now
Unlock full access