-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validation function Do not execute #275
Comments
I get the same issue as well... I cant get Any help will be highly appreciated! Thank you! |
check your secret key, i have same issue, try with put secret key directly. not with environment variable.
|
@Faustrata yes I have done that from the beginning. It does not fire the function at all,
I am quite confused 😕. Whats the version of Hapi & the jwt lib you are using? |
Ok, I think the reason why the validate function was not getting called was because the But one thing, I noticed is that only when the validation passes then Thanks for the great lib 👍 ! |
I meet the same issue, I put secret directly in the code but the validate function is not called. |
const Hapi = require('hapi');
const people = { // our "users database"
1: {
id: 1,
name: 'Jen Jones'
}
};
// bring your own validation function
const validate = async function (decoded, request, h) {
console.log("Test validate");
};
const init = async () => {
const server = new Hapi.Server({ port: 8000 });
// include our module here ↓↓
await server.register(require('../lib'));
server.auth.strategy('jwt', 'jwt',
{ key: 'NeverShareYourSecret', // Never Share your secret key
validate // validate function defined above
});
server.auth.default('jwt');
server.route([
{
method: "GET", path: "/", config: { auth: false },
handler: function(request, h) {
return {text: 'Token not required'};
}
},
{
method: 'GET', path: '/restricted', config: { auth: 'jwt' },
handler: function(request, h) {
const response = h.response({text: 'You used a Token!'});
response.header("Authorization", request.headers.authorization);
return response;
}
}
]);
await server.start();
return server;
}
init().then(server => {
console.log('Server running at:', server.info.uri);
})
.catch(err => {
console.log(err);
});
I want to test ‘’validation function”,but validation function Do not execute。
The text was updated successfully, but these errors were encountered: