2016-06-09 18:14:36 +03:00
|
|
|
var errors = require('../../errors'),
|
|
|
|
i18n = require('../../i18n');
|
|
|
|
|
|
|
|
function checkVersionMatch(req, res, next) {
|
|
|
|
var requestVersion = req.get('X-Ghost-Version'),
|
|
|
|
currentVersion = res.locals.safeVersion;
|
|
|
|
|
|
|
|
if (requestVersion && requestVersion !== currentVersion) {
|
2016-10-06 15:27:35 +03:00
|
|
|
return next(new errors.VersionMismatchError({
|
|
|
|
message: i18n.t('errors.middleware.api.versionMismatch', {requestVersion: requestVersion, currentVersion: currentVersion})
|
|
|
|
}));
|
2016-06-09 18:14:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = checkVersionMatch;
|