@@ -12,6 +12,7 @@ import {
12
12
import { ILogger , Logger } from '~/core' ;
13
13
import { DatabaseService } from '~/core/database' ;
14
14
import { ACTIVE , INACTIVE } from '~/core/database/query' ;
15
+ import { SessionHost } from '../authentication' ;
15
16
import { withoutScope } from '../authorization/dto' ;
16
17
import { ProjectStep } from '../project/dto' ;
17
18
import {
@@ -35,6 +36,7 @@ const rolesThatCanBypassWorkflow: Role[] = [Role.Administrator];
35
36
export class EngagementRules {
36
37
constructor (
37
38
private readonly db : DatabaseService ,
39
+ private readonly sessionHost : SessionHost ,
38
40
// eslint-disable-next-line @seedcompany/no-unused-vars
39
41
@Logger ( 'engagement:rules' ) private readonly logger : ILogger ,
40
42
) { }
@@ -317,6 +319,7 @@ export class EngagementRules {
317
319
currentUserRoles ?: Role [ ] ,
318
320
changeset ?: ID ,
319
321
) : Promise < EngagementStatusTransition [ ] > {
322
+ const session = this . sessionHost . current ;
320
323
if ( session . anonymous ) {
321
324
return [ ] ;
322
325
}
@@ -356,6 +359,7 @@ export class EngagementRules {
356
359
}
357
360
358
361
async canBypassWorkflow ( session : Session ) {
362
+ const session = this . sessionHost . current ;
359
363
const roles = session . roles . map ( withoutScope ) ;
360
364
return intersection ( rolesThatCanBypassWorkflow , roles ) . length > 0 ;
361
365
}
@@ -368,6 +372,7 @@ export class EngagementRules {
368
372
) {
369
373
// If current user's roles include a role that can bypass workflow
370
374
// stop the check here.
375
+ const session = this . sessionHost . current ;
371
376
const currentUserRoles = session . roles . map ( withoutScope ) ;
372
377
if ( intersection ( rolesThatCanBypassWorkflow , currentUserRoles ) . length > 0 ) {
373
378
return ;
0 commit comments