diff --git a/core/server/services/auth/authorize.js b/core/server/services/auth/authorize.js index a8fccff372..7598cac601 100644 --- a/core/server/services/auth/authorize.js +++ b/core/server/services/auth/authorize.js @@ -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) })); } }