Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Change cleartimeout() to lt.clearTimeout() (#534)
  • Loading branch information
wnxhaja authored and marshallswain committed Jun 22, 2017
1 parent 1708341 commit 4fa2f95
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/socket/handler.js
Expand Up @@ -103,7 +103,7 @@ export default function setupSocketHandler (app, options, { feathersParams, prov
// Clear any previous timeout if we have logged in again.
if (logoutTimer) {
debug(`Clearing old timeout.`);
clearTimeout(logoutTimer);
lt.clearTimeout(logoutTimer);
}

logoutTimer = lt.setTimeout(() => {
Expand Down
53 changes: 53 additions & 0 deletions test/integration/socketio.test.js
Expand Up @@ -322,6 +322,59 @@ describe('Socket.io authentication', function () {
});
});

describe('reauthenticating will extends jwt expiry', () => {
const longExpiringApp = createApplication({
secret: 'supersecret',
jwt: { expiresIn: '10s' }
}, 'socketio');

let longExpiringServer;
let longExpiringSocket;

before(done => {
longExpiringServer = longExpiringApp.listen(1338);
longExpiringServer.once('listening', () => {
longExpiringSocket = io('http://localhost:1338');
done();
});
});

after(() => {
longExpiringServer.close();
});

it('should not be logout after reauthenticate', done => {
const data = {
strategy: 'local',
email: 'admin@feathersjs.com',
password: 'admin'
};

// token expires in 10 secs
longExpiringSocket.emit('authenticate', data, (error, response) => {
expect(error).to.not.be.ok;
expect(response).to.be.ok;

// reauth at 5 secs
setTimeout(function () {
longExpiringSocket.emit('authenticate', response, (error, response) => {
expect(error).to.not.be.ok;
expect(response).to.be.ok;
});
}, 5 * 1000);

// check if token expiry exceeds 10 secs
setTimeout(function () {
longExpiringSocket.emit('users::find', {}, (error, response) => {
expect(error).to.not.be.ok;
expect(response).to.be.ok;
done();
});
}, 14 * 1000);
});
});
});

describe('when calling a protected service method', () => {
describe('when not authenticated', () => {
it('returns NotAuthenticated error', done => {
Expand Down

0 comments on commit 4fa2f95

Please sign in to comment.