-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy patherror.js
More file actions
78 lines (67 loc) · 2.25 KB
/
Copy patherror.js
File metadata and controls
78 lines (67 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const idrErr = require('../../utils/error')
class UserControllerError extends idrErr.IDRError {
alreadyInOrg (shortname, username) { // org
const err = {}
err.error = 'USER_ALREADY_IN_ORG'
err.message = `The user could not be updated because the user '${username}' already belongs to the '${shortname}' organization.`
return err
}
notAllowedToChangeOrganization () {
const err = {}
err.error = 'NOT_ALLOWED_TO_CHANGE_ORGANIZATION'
err.message = 'Only the Secretariat can change the organization for a user.'
return err
}
notAllowedToChangeField () {
// Welcome to the future
return {
error: 'NOT_ALLOWED_TO_CHANGE_FIELD',
message: 'Regular users can only update their contact info'
}
}
orgDnePathParam (shortname) { // org
const err = {}
err.error = 'ORG_DNE_PARAM'
err.message = `The '${shortname}' organization designated by the shortname path parameter does not exist.`
return err
}
userDne (username) { // org
const err = {}
err.error = 'USER_DNE'
err.message = `The user '${username}' designated by the username parameter does not exist.`
return err
}
duplicateUsername () { // org
const err = {}
err.error = 'DUPLICATE_USERNAME'
err.message = 'The username you have chosen already exists.'
return err
}
notSameOrgOrSecretariat () { // org
const err = {}
err.error = 'NOT_SAME_ORG_OR_SECRETARIAT'
err.message = 'This information can only be viewed by the users of the same organization or the Secretariat.'
return err
}
notOrgAdminOrSecretariatUpdate () {
const err = {}
err.error = 'NOT_ORG_ADMIN_OR_SECRETARIAT_UPDATE'
err.message = 'Contact your org Admin to update fields other than your name.'
return err
}
notSameUserOrSecretariat () { // super
const err = {}
err.error = 'NOT_SAME_USER_OR_SECRETARIAT'
err.message = 'This information can only be viewed or modified by the Secretariat, an Org Admin or if the requester is the user.'
return err
}
secretUpdateNotAllowed () {
const err = {}
err.error = 'SECRET_UPDATE_NOT_ALLOWED'
err.message = 'The secret field must be updated through the reset_secret endpoint'
return err
}
}
module.exports = {
UserControllerError
}