Replaced i18n.t w/ tpl helper in authorize.js (#13442)

refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
This commit is contained in:
Aleksander Chromik 2021-10-05 11:34:07 +02:00 committed by GitHub
parent 045ce4834c
commit b69c39ba13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,11 @@
const errors = require('@tryghost/errors');
const i18n = require('../../../shared/i18n');
const tpl = require('@tryghost/tpl');
const messages = {
authorizationFailed: 'Authorization failed',
missingContentMemberOrIntegration: 'Unable to determine the authenticated member or integration. Check the supplied Content API Key and ensure cookies are being passed through if member auth is failing.',
missingAdminUserOrIntegration: 'Unable to determine the authenticated user or integration. Check that cookies are being passed through if using session authentication.'
};
const authorize = {
authorizeContentApi(req, res, next) {
@ -12,8 +18,8 @@ const authorize = {
return next();
}
return next(new errors.NoPermissionError({
message: i18n.t('errors.middleware.auth.authorizationFailed'),
context: i18n.t('errors.middleware.auth.missingContentMemberOrIntegration')
message: tpl(messages.authorizationFailed),
context: tpl(messages.missingContentMemberOrIntegration)
}));
},
@ -25,8 +31,8 @@ const authorize = {
return next();
} else {
return next(new errors.NoPermissionError({
message: i18n.t('errors.middleware.auth.authorizationFailed'),
context: i18n.t('errors.middleware.auth.missingAdminUserOrIntegration')
message: tpl(messages.authorizationFailed),
context: tpl(messages.missingAdminUserOrIntegration)
}));
}
}