]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/authcmds/hello.c
Add lastemail field.
[irc/quakenet/newserv.git] / chanserv / authcmds / hello.c
index e2a05289948ed926e56c2538d1c01563641d48fd..8f8aebb0e8be94e39b630f2a111cc23d5f4b9c08 100644 (file)
@@ -7,6 +7,12 @@
  * CMDDESC: Creates a new user account.
  * CMDFUNC: csa_dohello
  * CMDPROTO: int csa_dohello(void *source, int cargc, char **cargv);
+ * CMDHELP: Usage: HELLO <email> <email>
+ * CMDHELP: Creates a new user account for yourself.  Your current nickname will be used
+ * CMDHELP: for the name of the account, and may only contain letters, numbers and 
+ * CMDHELP: hyphens (-).  An email containing password details will be sent to the email
+ * CMDHELP: address supplied.  Where:
+ * CMDHELP: email    - your email address.  Must be entered the same way both times.
  */
 
 #include "../chanserv.h"
@@ -24,6 +30,7 @@ int csa_dohello(void *source, int cargc, char **cargv) {
   reguser *ruh;
   int found=0;
   char *dupemail;
+  activeuser *aup;
 
   if (getreguserfromnick(sender))
     return CMD_ERROR;
@@ -38,6 +45,14 @@ int csa_dohello(void *source, int cargc, char **cargv) {
     return CMD_ERROR;
   }
 
+  if (!(aup = getactiveuserfromnick(sender)))
+    return CMD_ERROR;
+
+  if (aup->helloattempts > MAXHELLOS) {
+    chanservstdmessage(sender, QM_MAXHELLOLIMIT);
+    return CMD_ERROR;
+  }
+
   if (strcmp(cargv[0],cargv[1])) {
     chanservstdmessage(sender, QM_EMAILDONTMATCH);
     cs_log(sender,"HELLO FAIL username %s email don't match (%s vs %s)",sender->nick,cargv[0],cargv[1]);
@@ -47,44 +62,71 @@ int csa_dohello(void *source, int cargc, char **cargv) {
   if (csa_checkeboy(sender, cargv[0]))
     return CMD_ERROR;
 
-  mdp=findorcreatemaildomain(cargv[0]);
-  for(smdp=mdp; smdp; smdp=smdp->parent) {
-    if((smdp->count >= smdp->limit) && (smdp->limit > 0)) {
-      chanservstdmessage(sender, QM_DOMAINLIMIT);
-      return CMD_ERROR;
-    }
-  }
+  if (csa_checkaccountname(sender, sender->nick))
+    return CMD_ERROR;
 
   dupemail = strdup(cargv[0]);
   local=strchr(dupemail, '@');
+  if(!local)
+    return CMD_ERROR;
   *(local++)='\0';
-  for (ruh=mdp->users; ruh; ruh=ruh->nextbydomain) {
-    if (ruh->localpart)
-      if (!match(local, ruh->localpart->content)) {
-        found++;
+
+  mdp=findnearestmaildomain(local);
+  if(mdp) {
+    for(smdp=mdp; smdp; smdp=smdp->parent) {
+      if(MDIsBanned(smdp)) {
+        free(dupemail);
+        chanservstdmessage(sender, QM_DOMAINBANNED);
+        return CMD_ERROR;
+      }
+      if((smdp->count >= smdp->limit) && (smdp->limit > 0)) {
+        free(dupemail);
+        chanservstdmessage(sender, QM_DOMAINLIMIT);
+        return CMD_ERROR;
       }
+    }
   }
-  free(dupemail);
 
-  if((found > mdp->actlimit) && (mdp->actlimit > 0)) {
-    chanservstdmessage(sender, QM_DOMAINLIMIT);
-    return CMD_ERROR;
+  mdp=findmaildomainbydomain(local);
+  if(mdp) {
+    for (ruh=mdp->users; ruh; ruh=ruh->nextbydomain) {
+      if (ruh->localpart)
+        if (!strcasecmp(dupemail, ruh->localpart->content)) {
+          found++;
+        }
+    }
+
+    if((found >= mdp->actlimit) && (mdp->actlimit > 0)) {
+      free(dupemail);
+      chanservstdmessage(sender, QM_ADDRESSLIMIT);
+      return CMD_ERROR;
+    }
   }
 
+  mdp=findorcreatemaildomain(cargv[0]);
+
+  aup->helloattempts++;
+  
   rup=getreguser();
   rup->status=0;
   rup->ID=++lastuserID;
   strncpy(rup->username,sender->nick,NICKLEN); rup->username[NICKLEN]='\0';
   rup->created=time(NULL);
-  rup->lastauth=time(NULL);
+  rup->lastauth=0;
   rup->lastemailchange=time(NULL);
   rup->flags=QUFLAG_NOTICE;
   rup->languageid=0;
   rup->suspendby=0;
   rup->suspendexp=0;
+  rup->suspendtime=0;
+  rup->lockuntil=0;
   rup->password[0]='\0';
   rup->email=getsstring(cargv[0],EMAILLEN);
-  rup->localpart=getsstring(local,EMAILLEN);
+  rup->lastemail=NULL;
+
+  rup->localpart=getsstring(dupemail,EMAILLEN);
+  free(dupemail);
+
   rup->domain=mdp;
   addregusertomaildomain(rup, rup->domain);
   rup->info=NULL;