[AuthorizationManager] use a new NotAuthorizedError

This commit is contained in:
Jakob Ackermann 2020-08-20 11:50:35 +01:00
parent de518ea4eb
commit a8c51de510
2 changed files with 11 additions and 2 deletions

View file

@ -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())
}
},

View file

@ -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
}