]> jfr.im git - irc/atheme/atheme.git/commitdiff
nickserv/enforce: Only login user to target account if they weren't already.
authorJanik Kleinhoff <redacted>
Tue, 2 Sep 2014 07:56:51 +0000 (09:56 +0200)
committerJanik Kleinhoff <redacted>
Tue, 2 Sep 2014 11:37:21 +0000 (13:37 +0200)
Also fixes a minor oversight in commit 9942cab where the user would not
be properly logged out.

modules/nickserv/enforce.c

index 18beaff295a2994e1876c2c77e3fe10247f5fe9b..7b3486f6442ab70044a16cd2281fcd018bcdee3f 100644 (file)
@@ -374,28 +374,32 @@ static void ns_cmd_regain(sourceinfo_t *si, int parc, char *parv[])
                        return;
                }
 
-               /* if they are identified to another account, nuke their session first */
-               if (si->smu)
+               /* identify them to the target nick's account if they aren't yet */
+               if (si->smu != mn->owner)
                {
-                       command_success_nodata(si, _("You have been logged out of \2%s\2."), entity(si->smu)->name);
-
-                       if (ircd_on_logout(si->su, entity(si->smu)->name))
-                               /* logout killed the user... */
-                               return;
-                       si->smu->lastlogin = CURRTIME;
-                       MOWGLI_ITER_FOREACH_SAFE(n, tn, si->smu->logins.head)
-                       {
-                               if (n->data == si->su)
-                               {
-                                       mowgli_node_delete(n, &si->smu->logins);
-                                       mowgli_node_free(n);
-                                       break;
-                               }
-                       }
-                       si->smu = NULL;
-               }
+                       /* if they are identified to another account, nuke their session first */
+                       if (si->smu != NULL)
+                       {
+                               command_success_nodata(si, _("You have been logged out of \2%s\2."), entity(si->smu)->name);
 
-               myuser_login(si->service, si->su, mn->owner, true);
+                               if (ircd_on_logout(si->su, entity(si->smu)->name))
+                                       /* logout killed the user... */
+                                       return;
+                               si->smu->lastlogin = CURRTIME;
+                               MOWGLI_ITER_FOREACH_SAFE(n, tn, si->smu->logins.head)
+                               {
+                                       if (n->data == si->su)
+                                       {
+                                               mowgli_node_delete(n, &si->smu->logins);
+                                               mowgli_node_free(n);
+                                               break;
+                                       }
+                               }
+                               si->su->myuser = NULL;
+                       }
+
+                       myuser_login(si->service, si->su, mn->owner, true);
+               }
 
                return;
        }