File tree 3 files changed +63
-1
lines changed
3 files changed +63
-1
lines changed Original file line number Diff line number Diff line change 19
19
const APIError = require ( "../../api/APIError" ) ;
20
20
const { chkperm } = require ( "../../helpers" ) ;
21
21
const { TYPE_DIRECTORY } = require ( "../FSNodeContext" ) ;
22
+ const { LLListUsers } = require ( "../ll_operations/ll_listusers" ) ;
22
23
const { LLReadDir } = require ( "../ll_operations/ll_readdir" ) ;
23
24
const { LLReadShares } = require ( "../ll_operations/ll_readshares" ) ;
24
25
const { HLFilesystemOperation } = require ( "./definitions" ) ;
@@ -48,7 +49,10 @@ class HLReadDir extends HLFilesystemOperation {
48
49
namediff : await subject . get ( 'name' ) !== user . username
49
50
}
50
51
) ;
51
- if (
52
+ if ( subject . isRoot ) {
53
+ const ll_listusers = new LLListUsers ( ) ;
54
+ children = await ll_listusers . run ( this . values ) ;
55
+ } else if (
52
56
await subject . isUserDirectory ( ) &&
53
57
await subject . get ( 'name' ) !== user . username
54
58
) {
Original file line number Diff line number Diff line change
1
+ const { RootNodeSelector, NodeChildSelector } = require ( "../node/selectors" ) ;
2
+ const { LLFilesystemOperation } = require ( "./definitions" ) ;
3
+
4
+ class LLListUsers extends LLFilesystemOperation {
5
+ static description = `
6
+ List user directories which are relevant to the
7
+ current actor.
8
+ ` ;
9
+
10
+ async _run ( ) {
11
+ const { context } = this ;
12
+ const svc = context . get ( 'services' ) ;
13
+ const svc_permission = svc . get ( 'permission' ) ;
14
+ const svc_fs = svc . get ( 'filesystem' ) ;
15
+
16
+ const user = this . values . user ;
17
+ const issuers = await svc_permission . list_user_permission_issuers ( user ) ;
18
+
19
+ const nodes = [ ] ;
20
+
21
+ nodes . push ( await svc_fs . node ( new NodeChildSelector (
22
+ new RootNodeSelector ( ) ,
23
+ user . username ,
24
+ ) ) ) ;
25
+
26
+ for ( const issuer of issuers ) {
27
+ const node = await svc_fs . node ( new NodeChildSelector (
28
+ new RootNodeSelector ( ) ,
29
+ issuer . username ) ) ;
30
+ nodes . push ( node ) ;
31
+ }
32
+
33
+ return nodes ;
34
+ }
35
+ }
36
+
37
+ module . exports = {
38
+ LLListUsers,
39
+ } ;
Original file line number Diff line number Diff line change @@ -583,6 +583,25 @@ class PermissionService extends BaseService {
583
583
]
584
584
) ;
585
585
}
586
+
587
+ /**
588
+ * List the users that have any permissions granted to the
589
+ * specified user.
590
+ */
591
+ async list_user_permission_issuers ( user ) {
592
+ const rows = await this . db . read (
593
+ 'SELECT DISTINCT issuer_user_id FROM `user_to_user_permissions` ' +
594
+ 'WHERE `holder_user_id` = ?' ,
595
+ [ user . id ] ,
596
+ ) ;
597
+
598
+ const users = [ ] ;
599
+ for ( const row of rows ) {
600
+ users . push ( await get_user ( { id : row . issuer_user_id } ) ) ;
601
+ }
602
+
603
+ return users ;
604
+ }
586
605
587
606
get_parent_permissions ( permission ) {
588
607
const parent_perms = [ ] ;
You can’t perform that action at this time.
0 commit comments