Skip to content

Commit 7ffe148

Browse files
committed
cleanup
1 parent a5c5601 commit 7ffe148

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/index.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { error, fakeReply, verify } = require('./utils')
66
const pkg = require('../package.json')
77

88
/**
9-
* @type {Object|GrantManager}
9+
* @type {Object}
1010
* @private
1111
*
1212
* The plugin related options and instances.
@@ -85,20 +85,20 @@ function handleKeycloakValidation (tkn, reply) {
8585
* If yes, return cached user data. Otherwise
8686
* handle validation with help of Keycloak.
8787
*
88-
* @param {string} field The authorization field, e.g. the value of `Authorization`
89-
* @param {Function} reply The callback handler
88+
* @param {string} d The authorization field, e.g. the value of `Authorization`
89+
* @param {Function} done The callback handler
9090
*/
91-
function validate (field, reply) {
91+
function validate (field, done) {
9292
const tkn = token.create(field)
93-
const done = fakeReply(reply)
93+
const reply = fakeReply(done)
9494

9595
if (!tkn) {
96-
return done(error('unauthorized', error.msg.missing))
96+
return reply(error('unauthorized', error.msg.missing))
9797
}
9898

9999
cache.get(store, tkn, (err, cached) => {
100100
const isCached = cached && !err
101-
isCached ? done.continue(cached) : handleKeycloakValidation(tkn, done)
101+
isCached ? reply.continue(cached) : handleKeycloakValidation(tkn, reply)
102102
})
103103
}
104104

@@ -117,10 +117,7 @@ function validate (field, reply) {
117117
function strategy (server) {
118118
return {
119119
authenticate (request, reply) {
120-
return server.kjwt.validate(
121-
request.raw.req.headers.authorization,
122-
reply
123-
)
120+
return validate(request.raw.req.headers.authorization, reply)
124121
}
125122
}
126123
}

0 commit comments

Comments
 (0)