README
Puzzle Framework Authentication Module
Authentication module to be used together with Puzzle Framework.
To use this module, you will have to add the following code in your authentication module, in the "afterBoot" method of the module initialization class.
const passport = require("@puzzleframework/auth/Passport"); const passportMiddleware = require("@puzzleframework/auth/PassportMiddleware"); ... afterBoot() { ... passport(); passportMiddleware(); ... } ...
For example, to fetch the user you can add the following method in the same class.
/** * Fetches the correct user based on the payload read from the * JWT token. * * @param {Object} payload The JWT Payload. * * @return {User} */ fetchUser(payload) { const User = puzzle.models.get("User"); return User.findOne({ where: { id: payload.id } }); }