File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
2
2
import { Nil } from '@seedcompany/common' ;
3
3
import { ID , Session , UnauthorizedException } from '~/common' ;
4
4
import { Privileges } from '../authorization' ;
5
+ import { MissingContextException } from '../authorization/policy/conditions' ;
5
6
import { Workflow } from './define-workflow' ;
6
7
import {
7
8
ExecuteTransitionInput as ExecuteTransitionInputFn ,
@@ -104,9 +105,18 @@ export const WorkflowService = <W extends Workflow>(workflow: () => W) => {
104
105
}
105
106
106
107
canBypass ( session : Session ) {
107
- return this . privileges
108
- . for ( session , this . workflow . eventResource )
109
- . can ( 'create' ) ;
108
+ try {
109
+ return this . privileges
110
+ . for ( session , this . workflow . eventResource )
111
+ . can ( 'create' ) ;
112
+ } catch ( e ) {
113
+ if ( e instanceof MissingContextException ) {
114
+ // Missing context, means a condition was required.
115
+ // Therefore, bypass is not allowed, as the convention is "condition-less execute"
116
+ return false ;
117
+ }
118
+ throw e ;
119
+ }
110
120
}
111
121
112
122
protected getBypassIfValid (
You can’t perform that action at this time.
0 commit comments