Skip to content
This repository has been archived by the owner on Dec 21, 2018. It is now read-only.

Commit

Permalink
Cancel trust callbacks if the other fires.
Browse files Browse the repository at this point in the history
This fixes a bug that caused rejected statuses to get resubmitted the
next time that user did something while authenticated.
  • Loading branch information
mythmon committed Aug 14, 2012
1 parent 2e7f01c commit 73e8e61
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
3 changes: 0 additions & 3 deletions api.js
Expand Up @@ -31,6 +31,3 @@ exports.status = {
return utils.request('/api/v1/status/' + id + '/', 'DELETE', data);
}
};

function submitStatus(irc_handle, irc_channel, content) {
}
18 changes: 9 additions & 9 deletions auth.js
Expand Up @@ -40,17 +40,17 @@ this.AuthManager.prototype.notice = function(nick, message) {
this.AuthManager.prototype.checkUser = function(nick) {
var self = this;
var user = this._user(nick);
process.nextTick(function() {
if (user.auth) {
user.emitter.emit('authorized');
} else {
self._askNickserv(nick);
}
});
if (user.auth) {
process.nextTick(function() {
user.emitter.emit('authorized');
});
} else {
self._askNickserv(nick);
}
return user.emitter;
}
};

this.AuthManager.prototype._askNickserv = function(nick) {
var msg = 'status ' + nick;
client.say('nickserv', msg);
}
};
4 changes: 2 additions & 2 deletions standup-irc.js
Expand Up @@ -173,8 +173,8 @@ var commands = {
});
ret.once('error', function(code, data) {
if (code === 403) {
client.say(channel, "You don't have permissiont to do that. " +
"Do you own that status?");
client.say(channel, "You don't have permissiont to do " +
"that. Do you own that status?");
} else {
client.say(channel, "I'm a failure, I couldn't do it.");
}
Expand Down
16 changes: 13 additions & 3 deletions utils.js
Expand Up @@ -55,10 +55,20 @@ this.request = request;

this.ifAuthorized = function(user, channel, func) {
var a = authman.checkUser(user);
a.once('authorized', func);
a.once('unauthorized', function() {

function doTrust() {
a.removeListener(dontTrust);
func();
}

function dontTrust() {
a.removeListener(trust);
client.say(channel, "I don't trust you, " + user + ", " +
"are you identified with nickserv?");
});
}

a.once('authorized', doTrust);
a.once('unauthorized', dontTrust);

return a;
};

0 comments on commit 73e8e61

Please sign in to comment.