Skip to content

Commit

Permalink
Fixed bug which prevented authToken from being updated while already …
Browse files Browse the repository at this point in the history
…authenticated. Added new authTokenChange event.
  • Loading branch information
jondubois committed Jun 20, 2016
1 parent 4e8a101 commit 31f13f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ module.exports.destroy = function (options) {
return SCSocketCreator.destroy(options);
};

module.exports.version = '4.3.18';
module.exports.version = '4.3.19';
7 changes: 5 additions & 2 deletions lib/scsocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,17 @@ SCSocket.prototype._changeToUnauthenticatedState = function () {
if (oldState == this.AUTHENTICATED) {
SCEmitter.prototype.emit.call(this, 'deauthenticate');
}
SCEmitter.prototype.emit.call(this, 'authTokenChange', this.signedAuthToken);
}
};

SCSocket.prototype._changeToAuthenticatedState = function (signedAuthToken) {
this.signedAuthToken = signedAuthToken;
this.authToken = this._extractAuthTokenData(signedAuthToken);

if (this.authState != this.AUTHENTICATED) {
var oldState = this.authState;
this.authState = this.AUTHENTICATED;
this.signedAuthToken = signedAuthToken;
this.authToken = this._extractAuthTokenData(signedAuthToken);
var stateChangeData = {
oldState: oldState,
newState: this.authState,
Expand All @@ -354,6 +356,7 @@ SCSocket.prototype._changeToAuthenticatedState = function (signedAuthToken) {
SCEmitter.prototype.emit.call(this, 'authStateChange', stateChangeData);
SCEmitter.prototype.emit.call(this, 'authenticate', signedAuthToken);
}
SCEmitter.prototype.emit.call(this, 'authTokenChange', signedAuthToken);
};

SCSocket.prototype.decodeBase64 = function (encodedString) {
Expand Down

0 comments on commit 31f13f4

Please sign in to comment.