Add email argument to oregister
authorMichael Poole <mdpoole@troilus.org>
Mon, 15 Feb 2010 21:00:28 +0000 (16:00 -0500)
committerMichael Poole <mdpoole@troilus.org>
Mon, 15 Feb 2010 21:00:28 +0000 (16:00 -0500)
Conflicts:

src/nickserv.help

src/nickserv.c
src/nickserv.help

index 0fe822748805e6845a7ce1d2001d32ccf04bdd1c..a48565d6b1a6c085643099bd8280a634d309e590 100644 (file)
@@ -1300,15 +1300,34 @@ static NICKSERV_FUNC(cmd_oregister)
     char *mask;
     struct userNode *settee;
     struct handle_info *hi;
+    const char *pass, *email;
 
     NICKSERV_MIN_PARMS(3);
 
+    pass = argv[2];
+    argv[2] = "****";
+
     if (!is_valid_handle(argv[1])) {
         reply("NSMSG_BAD_HANDLE", argv[1]);
         return 0;
     }
 
-    if (argc < 4) {
+    if (argc < 5 || !nickserv_conf.email_enabled) {
+        email = NULL;
+    } else {
+        const char *str;
+        email = argv[4];
+        if (!is_valid_email_addr(email)) {
+            send_message(user, nickserv, "NSMSG_BAD_EMAIL_ADDR");
+            return 0;
+        }
+        if ((str = mail_prohibited_address(email))) {
+            send_message(user, nickserv, "NSMSG_EMAIL_PROHIBITED", email, str);
+            return 0;
+        }
+    }
+
+    if (argc < 4 || !strcmp(argv[3], "*")) {
         mask = NULL;
         settee = NULL;
     } else if (strchr(argv[3], '@')) {
@@ -1334,12 +1353,14 @@ static NICKSERV_FUNC(cmd_oregister)
         free(mask);
         return 0;
     }
-    if (!(hi = nickserv_register(user, settee, argv[1], argv[2], 0))) {
+    if (!(hi = nickserv_register(user, settee, argv[1], pass, 0))) {
         free(mask);
         return 0;
     }
     if (mask)
         string_list_append(hi->masks, mask);
+    if (email)
+        nickserv_set_email_addr(hi, email);
     return 1;
 }
 
index cee38d813cd84eab732ae20bcbdf368e0d8a09f1..81db93d336df0375ea73e9427962df3a16b95564 100644 (file)
         "You may use *Account instead of Nick as the name argument; the * makes $N use the name of an account directly (useful if the user is not online).",
         "$uSee Also:$u oaddmask");
 "OREGISTER" {
-        "/services/nickserv/disable_nicks" (
-        "/msg $N@$s OREGISTER <account> <password> <user@host|nick>",
+        "/services/nickserv/email_enabled && /services/nickserv/disable_nicks" (
+        "/msg $N@$s OREGISTER <account> <password> [user@host|nick|*] [email]",
         "Registers an account with $b$N$b using the specified account, password, and user@host. If the nick of an online user is specified, then that user's user@host is used.  If no nickname or hostmask is used, it uses a default hostmask the first time the user authenticates.",
+        "If an email is specified, the account will only be registered if the email is valid and not blacklisted and after registering, the email will be set on the account.",
         "$uSee Also:$u ounregister"
         );
-        "!/services/nickserv/disable_nicks" (
-        "/msg $N@$s OREGISTER <account> <password> <user@host|nick>",
+        "/services/nickserv/email_enabled && !/services/nickserv/disable_nicks" (
+        "/msg $N@$s OREGISTER <account> <password> [user@host|nick|*] [email]",
+        "Registers an account with $b$N$b using the specified account, password, and user@host. If the nick of an online user is specified, then that user's user@host is used.  If no nickname or hostmask is used, it uses a default hostmask the first time the user authenticates.",
+        "If an email is specified, the account will only be registered if the email is valid and not blacklisted and after registering, the email will be set on the account.",
+        "$uSee Also:$u oregnick, ounregister, ounregnick"
+        );
+        "!/services/nickserv/email_enabled && /services/nickserv/disable_nicks" (
+        "/msg $N@$s OREGISTER <account> <password> [user@host|nick|*]",
+        "Registers an account with $b$N$b using the specified account, password, and user@host. If the nick of an online user is specified, then that user's user@host is used.  If no nickname or hostmask is used, it uses a default hostmask the first time the user authenticates.",
+        "$uSee Also:$u ounregister"
+        );
+        "!/services/nickserv/email_enabled && !/services/nickserv/disable_nicks" (
+        "/msg $N@$s OREGISTER <account> <password> [user@host|nick|*]",
         "Registers an account with $b$N$b using the specified account, password, and user@host. If the nick of an online user is specified, then that user's user@host is used.  If no nickname or hostmask is used, it uses a default hostmask the first time the user authenticates.",
         "$uSee Also:$u oregnick, ounregister, ounregnick"
         );