File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ async function handleKeycloakValidation (tkn, h) {
121
121
await cache . set ( store , tkn , userData , expiresIn )
122
122
return h . authenticated ( userData )
123
123
} catch ( err ) {
124
- throw raiseUnauthorized ( err , errorMessages . invalid , err . message )
124
+ throw raiseUnauthorized ( errorMessages . invalid , err . message )
125
125
}
126
126
}
127
127
@@ -143,7 +143,7 @@ async function validate (field, h = (data) => data) {
143
143
const reply = fakeToolkit ( h )
144
144
145
145
if ( ! tkn ) {
146
- throw raiseUnauthorized ( null , errorMessages . missing )
146
+ throw raiseUnauthorized ( errorMessages . missing )
147
147
}
148
148
149
149
const cached = await cache . get ( store , tkn )
Original file line number Diff line number Diff line change @@ -111,14 +111,16 @@ function verify (opts) {
111
111
* message. Otherwise the provided message.
112
112
*
113
113
* @param {Error|null|undefined } err The error object
114
- * @param {string } msg The error message
114
+ * @param {string } message The error message
115
+ * @param {string } reason The reason for the thrown error
115
116
* @param {string } [scheme = 'Bearer'] The related scheme
116
117
* @returns {Boom.unauthorized } The created `Boom` error
117
118
*/
118
- function raiseUnauthorized ( err , msg , reason , scheme = 'Bearer' ) {
119
- return boom . unauthorized ( err ? err . message : msg , scheme , {
119
+ function raiseUnauthorized ( error , reason , scheme = 'Bearer' ) {
120
+ return boom . unauthorized ( null , scheme , {
120
121
strategy : 'keycloak-jwt' ,
121
- ...( reason && ! err ? { reason } : { } )
122
+ ...( error ? { error } : { } ) ,
123
+ ...( reason && error !== reason ? { reason } : { } )
122
124
} )
123
125
}
124
126
You can’t perform that action at this time.
0 commit comments