Skip to content
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

As soon as my token expires, it doesn't hit validateFunc #244

Closed
rathorer opened this issue Jul 15, 2017 · 1 comment
Closed

As soon as my token expires, it doesn't hit validateFunc #244

rathorer opened this issue Jul 15, 2017 · 1 comment

Comments

@rathorer
Copy link

rathorer commented Jul 15, 2017

I was trying to implement refresh-token functionality for my app using hapi-auth-jwt2. What I was trying if token expires, trigger a refresh-token call to get a new token if user is still active from client side, and in validateFunc just bypass the expiration check and issue a new token from handler. But I get 401 'Invalid token' for the refresh-token without it calling validateFunc

var jwtValidate = function (decoded, request, callback) {
    var expDate = decoded.exp * 1000;
    if (request.path.indexOf('refreshToken') < 0) {
        if (Date.now() > expDate) {
            throw Boom.unauthorized('Token expired, please login again.');
        }
        var user = users.find(function(a){
            return a[decoded.id]
        });
        if(user){
            callback(null, true);
        } else{
            Boom.unauthorized('No such active user.');
        }
    }
};

Is this the expected behavior? if yes, how should I implement refresh functionality? I referred #237 which also depends on expDate.

@rathorer
Copy link
Author

rathorer commented Jul 15, 2017

Hi, closing issue as using ignoreExpiration: true I am able to achieve what I wanted.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant