@openneuro/server 4.3.0-alpha.0 → 4.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openneuro/server",
|
|
3
|
-
"version": "4.3.0-alpha.
|
|
3
|
+
"version": "4.3.0-alpha.1",
|
|
4
4
|
"description": "Core service for the OpenNeuro platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/server.js",
|
|
@@ -89,7 +89,6 @@
|
|
|
89
89
|
"ioredis-mock": "^3.8.1",
|
|
90
90
|
"jest": "^26.6.3",
|
|
91
91
|
"mockingoose": "2.11.0",
|
|
92
|
-
"mongo-mock": "3.7.1",
|
|
93
92
|
"nodemon": "^2.0.7",
|
|
94
93
|
"supertest": "^3.0.0",
|
|
95
94
|
"ts-node-dev": "1.1.6",
|
|
@@ -104,5 +103,5 @@
|
|
|
104
103
|
"publishConfig": {
|
|
105
104
|
"access": "public"
|
|
106
105
|
},
|
|
107
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "7bddf78a87c14fc36561344bf7170ee01582aa4e"
|
|
108
107
|
}
|
|
@@ -3,24 +3,13 @@ import { users } from '../user.js'
|
|
|
3
3
|
describe('user resolvers', () => {
|
|
4
4
|
describe('users()', () => {
|
|
5
5
|
it('throws an error for non-admins', () => {
|
|
6
|
-
expect(
|
|
6
|
+
expect(
|
|
7
7
|
users(
|
|
8
8
|
null,
|
|
9
9
|
{ id: '3311cfe8-9764-434d-b80e-1b1ee72c686d' },
|
|
10
10
|
{ userInfo: {} },
|
|
11
11
|
),
|
|
12
|
-
).
|
|
13
|
-
})
|
|
14
|
-
it('admins should be able to override restrictions', () => {
|
|
15
|
-
expect(() =>
|
|
16
|
-
users(
|
|
17
|
-
null,
|
|
18
|
-
{ id: '3311cfe8-9764-434d-b80e-1b1ee72c686d' },
|
|
19
|
-
{
|
|
20
|
-
userInfo: { admin: true },
|
|
21
|
-
},
|
|
22
|
-
),
|
|
23
|
-
).not.toThrowError()
|
|
12
|
+
).rejects.toEqual(new Error('You must be a site admin to retrieve users'))
|
|
24
13
|
})
|
|
25
14
|
})
|
|
26
15
|
})
|
|
@@ -13,7 +13,9 @@ export const users = (obj, args, { userInfo }) => {
|
|
|
13
13
|
if (userInfo.admin) {
|
|
14
14
|
return User.find().exec()
|
|
15
15
|
} else {
|
|
16
|
-
|
|
16
|
+
return Promise.reject(
|
|
17
|
+
new Error('You must be a site admin to retrieve users'),
|
|
18
|
+
)
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -21,7 +23,7 @@ export const removeUser = (obj, { id }, { userInfo }) => {
|
|
|
21
23
|
if (userInfo.admin) {
|
|
22
24
|
return User.findByIdAndRemove(id).exec()
|
|
23
25
|
} else {
|
|
24
|
-
|
|
26
|
+
return Promise.reject(new Error('You must be a site admin to remove users'))
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -29,7 +31,9 @@ export const setAdmin = (obj, { id, admin }, { userInfo }) => {
|
|
|
29
31
|
if (userInfo.admin) {
|
|
30
32
|
return User.findOneAndUpdate({ id }, { admin }).exec()
|
|
31
33
|
} else {
|
|
32
|
-
|
|
34
|
+
return Promise.reject(
|
|
35
|
+
new Error('You must be a site admin to modify this value'),
|
|
36
|
+
)
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
|
|
@@ -37,7 +41,7 @@ export const setBlocked = (obj, { id, blocked }, { userInfo }) => {
|
|
|
37
41
|
if (userInfo.admin) {
|
|
38
42
|
return User.findOneAndUpdate({ id }, { blocked }).exec()
|
|
39
43
|
} else {
|
|
40
|
-
|
|
44
|
+
return Promise.reject(new Error('You must be a site admin to block a user'))
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
|