* Iterates over the parents of the resource, returns who has read / write * rights for this resource
(store: Store)
| 170 | * rights for this resource |
| 171 | */ |
| 172 | async getRights(store: Store): Promise<Right[]> { |
| 173 | const rights: Right[] = []; |
| 174 | const write: string[] = this.getArray(properties.write); |
| 175 | write.forEach((subject: string) => { |
| 176 | rights.push({ |
| 177 | for: subject, |
| 178 | type: RightType.WRITE, |
| 179 | setIn: this.subject, |
| 180 | }); |
| 181 | }); |
| 182 | |
| 183 | const read: string[] = this.getArray(properties.read); |
| 184 | read.forEach((subject: string) => { |
| 185 | rights.push({ |
| 186 | for: subject, |
| 187 | type: RightType.READ, |
| 188 | setIn: this.subject, |
| 189 | }); |
| 190 | }); |
| 191 | const parentSubject = this.get(properties.parent) as string; |
| 192 | if (parentSubject != undefined) { |
| 193 | if (parentSubject == this.getSubject()) { |
| 194 | console.warn('Circular parent', parentSubject); |
| 195 | return rights; |
| 196 | } |
| 197 | const parent = await store.getResourceAsync(parentSubject); |
| 198 | const parentRights = await parent.getRights(store); |
| 199 | rights.push(...parentRights); |
| 200 | } |
| 201 | console.log('rights', rights); |
| 202 | return rights; |
| 203 | } |
| 204 | |
| 205 | /** Returns true is the resource had an `Unauthorized` 401 response. */ |
| 206 | isUnauthorized(): boolean { |
no test coverage detected