mirror of
https://hk.gh-proxy.com/https://github.com/NodeBB/nodebb-plugin-2factor.git
synced 2025-10-03 09:11:01 +08:00
17 lines
413 B
JavaScript
17 lines
413 B
JavaScript
'use strict';
|
|
|
|
const translator = require.main.require('./src/translator');
|
|
|
|
const Middlewares = module.exports;
|
|
|
|
Middlewares.requireSecondFactor = function (req, res, next) {
|
|
if (req.session.hasOwnProperty('tfa') && req.session.tfa === true) {
|
|
next();
|
|
} else {
|
|
translator.translate('[[2factor:second-factor-required]]', (translated) => {
|
|
res.status(403).json({
|
|
error: translated,
|
|
});
|
|
});
|
|
}
|
|
};
|