secajs/src/middlewares/redirectIfMissingProfileDetailsMiddleware.js

16 lines
557 B
JavaScript
Raw Normal View History

2025-03-05 15:04:27 +01:00
const profileServiceProvider = require('../services/profileService');
const ContactDetailsSet = require('../models/ContactDetailsSet');
const NymSet = require('../models/NymSet');
const profileService = profileServiceProvider(ContactDetailsSet, NymSet);
async function redirectIfMissingProfileDetailsMiddleware(req, res, next) {
const publicKey = req.cookies.publicKey;
if (!(await profileService.areProfileDetailsComplete(publicKey))) {
res.redirect('/createProfile');
}
next();
}
module.exports = redirectIfMissingProfileDetailsMiddleware;