-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
It should be possible to configure LoopBack application in such way that the access token expires after a certain time of inactivity. The current implementation supports only the expiration after a fixed time since login.
See strongloop/loopback-sdk-angular#39 for a possible solution:
// ...
app.use(loopback.token({/* config */});
app.use(function(req, res, next) {
var token = req.accessToken;
if (!token) return next();
var now = new Date();
// performance optimization:
// do not update the token more often than once per second
if (now.getTime() - token.created.getTime() < 1000) return;
// update the token and save the changes
req.accessToken.created = now;
req.accessToken.ttl = 60; /* session timeout in seconds */
req.accessToken.save(next);
});
// register other middleware, etc.Un3qual, acrodrig, rahpuser, tamitutor, manishsharma16 and 6 moreappsolzone, febeks and farruxx