rearrange chanserv-level ban/kick messages; change wording on authentication cookie...
[srvx.git] / src / nickserv.c
index 8c49603919f9ff004548d115acbc4f86ceb9b7be..65ca14ef1f7f39463e47c3ae9c218f2a94bc1f5b 100644 (file)
@@ -157,6 +157,7 @@ static const struct message_entry msgtab[] = {
     { "NSMSG_MUST_TIME_OUT", "You must wait for cookies of that type to time out." },
     { "NSMSG_ATE_COOKIE", "I ate the cookie for your account.  You may now have another." },
     { "NSMSG_USE_RENAME", "You are already authenticated to account $b%s$b -- contact the support staff to rename your account." },
+    { "NSMSG_ALREADY_REGISTERING", "You have already used $bREGISTER$b once this session; you may not use it again." },
     { "NSMSG_REGISTER_BAD_NICKMASK", "Could not recognize $b%s$b as either a current nick or a hostmask." },
     { "NSMSG_NICK_NOT_REGISTERED", "Nick $b%s$b has not been registered to any account." },
     { "NSMSG_HANDLE_NOT_FOUND", "Could not find your account -- did you register yet?" },
@@ -278,7 +279,7 @@ static const struct message_entry msgtab[] = {
     { "NSMSG_SET_LEVEL", "$bLEVEL:        $b%d" },
     { "NSMSG_SET_EPITHET", "$bEPITHET:      $b%s" },
     { "NSEMAIL_ACTIVATION_SUBJECT", "Account verification for %s" },
-    { "NSEMAIL_ACTIVATION_BODY", "This email has been sent to verify that this email address belongs to the person who tried to register an account on %1$s.  Your cookie is:\n    %2$s\nTo verify your email address and complete the account registration, log on to %1$s and type the following command:\n    /msg %3$s@%4$s COOKIE %5$s %2$s\nIf you did NOT request this account, you do not need to do anything.  Please contact the %1$s staff if you have questions." },
+    { "NSEMAIL_ACTIVATION_BODY", "This email has been sent to verify that this email address belongs to the person who tried to register an account on %1$s.  Your cookie is:\n    %2$s\nTo verify your email address and complete the account registration, log on to %1$s and type the following command:\n    /msg %3$s@%4$s COOKIE %5$s %2$s\nThis command is only used once to complete your account registration, and never again. Once you have run this command, you will need to authenticate everytime you reconnect to the network. To do this, you will have to type this command every time you reconnect:\n    /msg %3$s@%4$s AUTH %1$s your-password\n Please remember to fill in 'your-password' with the actual password you gave to us when you registered.\n\nIf you did NOT request this account, you do not need to do anything.  Please contact the %1$s staff if you have questions, and be sure to check our website." },
     { "NSEMAIL_PASSWORD_CHANGE_SUBJECT", "Password change verification on %s" },
     { "NSEMAIL_PASSWORD_CHANGE_BODY", "This email has been sent to verify that you wish to change the password on your account %5$s.  Your cookie is %2$s.\nTo complete the password change, log on to %1$s and type the following command:\n    /msg %3$s@%4$s COOKIE %5$s %2$s\nIf you did NOT request your password to be changed, you do not need to do anything.  Please contact the %1$s staff if you have questions." },
     { "NSEMAIL_EMAIL_CHANGE_SUBJECT", "Email address change verification for %s" },
@@ -673,7 +674,10 @@ smart_get_handle_info(struct userNode *service, struct userNode *user, const cha
             return 0;
         }
         if (IsLocal(target)) {
-            send_message(user, service, "NSMSG_USER_IS_SERVICE", target->nick);
+           if (IsService(target))
+                send_message(user, service, "NSMSG_USER_IS_SERVICE", target->nick);
+           else
+                send_message(user, service, "MSG_USER_AUTHENTICATE", target->nick);
             return 0;
         }
         if (!(hi = target->handle_info)) {
@@ -1081,6 +1085,11 @@ static NICKSERV_FUNC(cmd_register)
         return 0;
     }
 
+    if (IsRegistering(user)) {
+        reply("NSMSG_ALREADY_REGISTERING");
+       return 0;
+    }
+
     if (IsStamped(user)) {
         /* Unauthenticated users might still have been stamped
            previously and could therefore have a hidden host;
@@ -1163,6 +1172,9 @@ static NICKSERV_FUNC(cmd_register)
     if (no_auth)
         nickserv_make_cookie(user, hi, ACTIVATION, hi->passwd);
 
+    /* Set registering flag.. */
+    user->modes |= FLAGS_REGISTERING; 
+
     return 1;
 }
 
@@ -2698,19 +2710,17 @@ static NICKSERV_FUNC(cmd_merge)
         for (cList2=hi_to->channels; cList2; cList2=cList2->u_next)
             if (cList->channel == cList2->channel)
                 break;
-        log_module(NS_LOG, LOG_DEBUG, "Merging %s->%s@%s: before %p->%p->%-p, %p->%p->%p",
-                   hi_from->handle, hi_to->handle, cList->channel->channel->name,
-                   cList->u_prev, cList, cList->u_next,
-                   (cList2?cList2->u_prev:0), cList2, (cList2?cList2->u_next:0));
         if (cList2 && (cList2->access >= cList->access)) {
+            log_module(NS_LOG, LOG_INFO, "Merge: %s had only %d access in %s (versus %d for %s)", hi_from->handle, cList->access, cList->channel->channel->name, cList2->access, hi_to->handle);
             /* keep cList2 in hi_to; remove cList from hi_from */
-            log_module(NS_LOG, LOG_DEBUG, "Deleting %p", cList);
             del_channel_user(cList, 1);
         } else {
             if (cList2) {
+                log_module(NS_LOG, LOG_INFO, "Merge: %s had only %d access in %s (versus %d for %s)", hi_to->handle, cList2->access, cList->channel->channel->name, cList->access, hi_from->handle);
                 /* remove the lower-ranking cList2 from hi_to */
-                log_module(NS_LOG, LOG_DEBUG, "Deleting %p", cList2);
                 del_channel_user(cList2, 1);
+            } else {
+                log_module(NS_LOG, LOG_INFO, "Merge: %s had no access in %s", hi_to->handle, cList->channel->channel->name);
             }
             /* cList needs to be moved from hi_from to hi_to */
             cList->handle = hi_to;
@@ -2725,8 +2735,6 @@ static NICKSERV_FUNC(cmd_merge)
             if (hi_to->channels)
                 hi_to->channels->u_prev = cList;
             hi_to->channels = cList;
-            log_module(NS_LOG, LOG_DEBUG, "Now %p->%p->%p",
-                       cList->u_prev, cList, cList->u_next);
         }
     }
 
@@ -3438,6 +3446,7 @@ nickserv_conf_read(void)
 
 static void
 nickserv_reclaim(struct userNode *user, struct nick_info *ni, enum reclaim_action action) {
+    const char *msg;
     char newnick[NICKLEN+1];
 
     assert(user);
@@ -3456,7 +3465,8 @@ nickserv_reclaim(struct userNode *user, struct nick_info *ni, enum reclaim_actio
         irc_svsnick(nickserv, user, newnick);
         break;
     case RECLAIM_KILL:
-        irc_kill(nickserv, user, "NSMSG_RECLAIM_KILL");
+        msg = user_find_message(user, "NSMSG_RECLAIM_KILL");
+        irc_kill(nickserv, user, msg);
         break;
     }
 }