0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

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 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 = { const authorize = {
authorizeContentApi(req, res, next) { authorizeContentApi(req, res, next) {
@ -12,8 +18,8 @@ const authorize = {
return next(); return next();
} }
return next(new errors.NoPermissionError({ return next(new errors.NoPermissionError({
message: i18n.t('errors.middleware.auth.authorizationFailed'), message: tpl(messages.authorizationFailed),
context: i18n.t('errors.middleware.auth.missingContentMemberOrIntegration') context: tpl(messages.missingContentMemberOrIntegration)
})); }));
}, },
@ -25,8 +31,8 @@ const authorize = {
return next(); return next();
} else { } else {
return next(new errors.NoPermissionError({ return next(new errors.NoPermissionError({
message: i18n.t('errors.middleware.auth.authorizationFailed'), message: tpl(messages.authorizationFailed),
context: i18n.t('errors.middleware.auth.missingAdminUserOrIntegration') context: tpl(messages.missingAdminUserOrIntegration)
})); }));
} }
} }