4. Add authentication routes

Making use of the passport SIWW strategy and the token library, we defined the oAuth2 routes.

const express = require('express');
const router = express.Router();
const authToken = require('../authenticate/token');
const passportSIWW = require("../authenticate/passport_siww");    

// login via passport-wallet + SIWW
router.get('/siww',passportSIWW.authenticate('SIWW', {session: false}));
router.get('/siww/callback', passportSIWW.authenticate('SIWW', {
    failureRedirect: '/auth/unauthorized',
    session: false
}), function (req, res) {

    // make the auth cookie and redirect
    let token=authToken.createToken(req);
    res.cookie(authToken.getCookieName(), token, authToken.getCookieOptions());
        res.redirect('/app');
    });

Last updated