Permalink
Browse files

Cancel trust callbacks if the other fires.

This fixes a bug that caused rejected statuses to get resubmitted the
next time that user did something while authenticated.
  • Loading branch information...
1 parent 2e7f01c commit 73e8e61fa4258be948cecc49d8cf8215c84c45bf @mythmon mythmon committed Aug 14, 2012
Showing with 24 additions and 17 deletions.
  1. +0 −3 api.js
  2. +9 −9 auth.js
  3. +2 −2 standup-irc.js
  4. +13 −3 utils.js
View
3 api.js
@@ -31,6 +31,3 @@ exports.status = {
return utils.request('/api/v1/status/' + id + '/', 'DELETE', data);
}
};
-
-function submitStatus(irc_handle, irc_channel, content) {
-}
View
18 auth.js
@@ -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);
-}
+};
View
@@ -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.");
}
View
@@ -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.