diff --git a/services/real-time/app/js/AuthorizationManager.js b/services/real-time/app/js/AuthorizationManager.js index a545594479..0c37ac1423 100644 --- a/services/real-time/app/js/AuthorizationManager.js +++ b/services/real-time/app/js/AuthorizationManager.js @@ -1,6 +1,8 @@ /* eslint-disable camelcase, */ +const { NotAuthorizedError } = require('./Errors') + let AuthorizationManager module.exports = AuthorizationManager = { assertClientCanViewProject(client, callback) { @@ -23,7 +25,7 @@ module.exports = AuthorizationManager = { if (allowedLevels.includes(client.ol_context.privilege_level)) { callback(null) } else { - callback(new Error('not authorized')) + callback(new NotAuthorizedError()) } }, @@ -49,7 +51,7 @@ module.exports = AuthorizationManager = { if (client.ol_context[`doc:${doc_id}`] === 'allowed') { callback(null) } else { - callback(new Error('not authorized')) + callback(new NotAuthorizedError()) } }, diff --git a/services/real-time/app/js/Errors.js b/services/real-time/app/js/Errors.js index 7a039c54c1..57190b75e5 100644 --- a/services/real-time/app/js/Errors.js +++ b/services/real-time/app/js/Errors.js @@ -21,6 +21,12 @@ class MissingSessionError extends OError { } } +class NotAuthorizedError extends OError { + constructor() { + super('not authorized') + } +} + class NullBytesInOpError extends OError { constructor(jsonChange) { super('null bytes found in op', { jsonChange }) @@ -37,6 +43,7 @@ module.exports = { CodedError, DataTooLargeToParseError, MissingSessionError, + NotAuthorizedError, NullBytesInOpError, UpdateTooLargeError }