Skip to content

Commit cc89922

Browse files
committed
Fix typing that was broken to repair tests
1 parent 6c00cc8 commit cc89922

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ParseACL.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ export default class ParseACL {
118118
if (userId instanceof ParseUser) {
119119
userId = userId.id;
120120
} else if (userId instanceof ParseRole) {
121-
userId = 'role:' + userId.getName();
121+
const name = userId.getName();
122+
if (!name) {
123+
throw new TypeError('Role must have a name');
124+
}
125+
userId = 'role:' + name;
122126
}
123127
if (typeof userId !== 'string') {
124128
throw new TypeError('userId must be a string.');
@@ -157,7 +161,11 @@ export default class ParseACL {
157161
throw new Error('Cannot get access for a ParseUser without an ID');
158162
}
159163
} else if (userId instanceof ParseRole) {
160-
userId = 'role:' + userId.getName();
164+
const name = userId.getName();
165+
if (!name) {
166+
throw new TypeError('Role must have a name');
167+
}
168+
userId = 'role:' + name;
161169
}
162170
var permissions = this.permissionsById[userId];
163171
if (!permissions) {

0 commit comments

Comments
 (0)