]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/nickserv.c
Try again to correct the issue. :/
[irc/evilnet/x3.git] / src / nickserv.c
index a5f3149f1a8dca2e3ca466070a213d6039dc5242..05445d55332ed904607edc020eb388fdc512b911 100644 (file)
@@ -568,11 +568,18 @@ static void
 nickserv_unregister_handle(struct handle_info *hi, struct userNode *notify, struct userNode *bot)
 {
     unsigned int n;
+    struct userNode *uNode;
 
     for (n=0; n<unreg_func_used; n++)
         unreg_func_list[n](notify, hi);
-    while (hi->users)
+    while (hi->users) {
+        if (nickserv_conf.sync_log) {
+            uNode = GetUserH(hi->users->nick);
+            if (uNode)
+                irc_delete(uNode);
+        }
         set_user_handle_info(hi->users, NULL, 0);
+    }
     if (notify) {
         if (nickserv_conf.disable_nicks)
             send_message(notify, bot, "NSMSG_UNREGISTER_SUCCESS", hi->handle);
@@ -581,7 +588,7 @@ nickserv_unregister_handle(struct handle_info *hi, struct userNode *notify, stru
     }
 
     if (nickserv_conf.sync_log)
-      SyncLog("UNREGISTER %s", hi->handle);
+        SyncLog("UNREGISTER %s", hi->handle);
 
     dict_remove(nickserv_handle_dict, hi->handle);
 }
@@ -1342,7 +1349,7 @@ static NICKSERV_FUNC(cmd_register)
     if (nickserv_conf.sync_log) {
       cryptpass(password, syncpass);
       /*
-       * An 0 is only sent if theres no email address. Thios should only happen if email functions are
+      * An 0 is only sent if theres no email address. Thios should only happen if email functions are
        * disabled which they wont be for us. Email Required MUST be set on if you are using this.
        * -SiRVulcaN
        */
@@ -1361,19 +1368,26 @@ static NICKSERV_FUNC(cmd_oregister)
     struct userNode *settee;
     struct handle_info *hi;
 
-    NICKSERV_MIN_PARMS(4);
+    NICKSERV_MIN_PARMS(nickserv_conf.email_required ? 5 : 4);
 
     if (!is_valid_handle(argv[1])) {
         reply("NSMSG_BAD_HANDLE", argv[1]);
         return 0;
     }
 
+    if (nickserv_conf.email_required) {
+        if (!is_valid_email_addr(argv[4])) {
+            reply("NSMSG_BAD_EMAIL_ADDR");
+            return 0;
+        }
+    }
+
     if (strchr(argv[3], '@')) {
        mask = canonicalize_hostmask(strdup(argv[3]));
        if (argc > 4) {
-           settee = GetUserH(argv[4]);
+           settee = GetUserH(nickserv_conf.email_required ? argv[5] : argv[4]);
            if (!settee) {
-               reply("MSG_NICK_UNKNOWN", argv[4]);
+               reply("MSG_NICK_UNKNOWN", nickserv_conf.email_required ? argv[5] : argv[4]);
                 free(mask);
                return 0;
            }
@@ -1392,6 +1406,11 @@ static NICKSERV_FUNC(cmd_oregister)
         return 0;
     }
     if (!(hi = nickserv_register(user, settee, argv[1], argv[2], 0))) {
+        if (nickserv_conf.email_required) {
+            nickserv_set_email_addr(hi, argv[4]);
+            if (nickserv_conf.sync_log)
+                SyncLog("REGISTER %s %s %s %s", hi->handle, hi->passwd, argv[4], user->info);
+        }
         free(mask);
         return 0;
     }
@@ -1613,6 +1632,7 @@ static NICKSERV_FUNC(cmd_nickinfo)
 static NICKSERV_FUNC(cmd_rename_handle)
 {
     struct handle_info *hi;
+    struct userNode *uNode;
     char msgbuf[MAXLEN], *old_handle;
     unsigned int nn;
 
@@ -1639,6 +1659,15 @@ static NICKSERV_FUNC(cmd_rename_handle)
     for (nn=0; nn<rf_list_used; nn++)
         rf_list[nn](hi, old_handle);
     snprintf(msgbuf, sizeof(msgbuf), "%s renamed account %s to %s.", user->handle_info->handle, old_handle, hi->handle);
+
+
+    if (nickserv_conf.sync_log) {
+        for (uNode = hi->users; uNode; uNode = uNode->next_authed)
+            irc_rename(uNode, hi->handle);
+
+        SyncLog("RENAME %s %s", old_handle, hi->handle);
+    }
+
     reply("NSMSG_HANDLE_CHANGED", old_handle, hi->handle);
     global_message(MESSAGE_RECIPIENT_STAFF, msgbuf);
     free(old_handle);
@@ -2093,7 +2122,8 @@ static NICKSERV_FUNC(cmd_cookie)
            * This should only happen if an OREGISTER was sent. Require
            * email must be enabled! - SiRVulcaN
            */
-          SyncLog("REGISTER %s %s %s %s", hi->handle, hi->passwd, hi->cookie->data, user->info);
+          if (nickserv_conf.sync_log)
+            SyncLog("REGISTER %s %s %s %s", hi->handle, hi->passwd, hi->cookie->data, user->info);
         }
         nickserv_set_email_addr(hi, hi->cookie->data);
         reply("NSMSG_EMAIL_CHANGED");
@@ -2561,6 +2591,9 @@ static OPTION_FUNC(opt_password)
     if (argc > 1)
        cryptpass(argv[1], hi->passwd);
 
+    if (nickserv_conf.sync_log)
+        SyncLog("PASSCHANGE %s %s", hi->handle, hi->passwd);
+
     send_message(user, nickserv, "NSMSG_SET_PASSWORD", "***");
     return 1;
 }