@@ -53,7 +53,9 @@ module.exports = (app) => {
53
53
if ( req . authUser . isMachine ) {
54
54
// M2M
55
55
if ( ! req . authUser . scopes || ! helper . checkIfExists ( def . scopes , req . authUser . scopes ) ) {
56
- next ( new errors . ForbiddenError ( "You are not allowed to perform this action!" ) ) ;
56
+ next ( new errors . ForbiddenError ( `You are not allowed to perform this action, because the scopes are incorrect. \
57
+ Required scopes: ${ JSON . stringify ( def . scopes ) } \
58
+ Provided scopes: ${ JSON . stringify ( req . authUser . scopes ) } ` ) ) ;
57
59
} else {
58
60
req . authUser . handle = config . M2M_AUDIT_HANDLE ;
59
61
req . authUser . userId = config . M2M_AUDIT_USERID ;
@@ -71,14 +73,17 @@ module.exports = (app) => {
71
73
_ . map ( req . authUser . roles , ( r ) => r . toLowerCase ( ) )
72
74
)
73
75
) {
74
- next ( new errors . ForbiddenError ( "You are not allowed to perform this action!" ) ) ;
76
+ next ( new errors . ForbiddenError ( `You are not allowed to perform this action, because the roles are incorrect. \
77
+ Required scopes: ${ JSON . stringify ( def . access ) } \
78
+ Provided scopes: ${ JSON . stringify ( req . authUser . roles ) } ` ) ) ;
75
79
} else {
76
80
// user token is used in create/update challenge to ensure user can create/update challenge under specific project
77
81
req . userToken = req . headers . authorization . split ( " " ) [ 1 ] ;
78
82
next ( ) ;
79
83
}
80
84
} else {
81
- next ( new errors . ForbiddenError ( "You are not authorized to perform this action" ) ) ;
85
+ next ( new errors . ForbiddenError ( "You are not authorized to perform this action, \
86
+ because no roles were provided" ) ) ;
82
87
}
83
88
}
84
89
} ) ;
0 commit comments