]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: hello | |
5 | * CMDLEVEL: QCMD_NOTAUTHED | |
6 | * CMDARGS: 2 | |
7 | * CMDDESC: Creates a new user account. | |
8 | * CMDFUNC: csa_dohello | |
9 | * CMDPROTO: int csa_dohello(void *source, int cargc, char **cargv); | |
50cd26d6 | 10 | * CMDHELP: Usage: HELLO <email> <email> |
11 | * CMDHELP: Creates a new user account for yourself. Your current nickname will be used | |
12 | * CMDHELP: for the name of the account, and may only contain letters, numbers and | |
13 | * CMDHELP: hyphens (-). An email containing password details will be sent to the email | |
14 | * CMDHELP: address supplied. Where: | |
15 | * CMDHELP: email - your email address. Must be entered the same way both times. | |
1dd6d55d | 16 | */ |
17 | ||
18 | #include "../chanserv.h" | |
19 | #include "../authlib.h" | |
20 | #include "../../lib/irc_string.h" | |
21 | #include <stdio.h> | |
22 | #include <string.h> | |
23 | ||
24 | int csa_dohello(void *source, int cargc, char **cargv) { | |
25 | nick *sender=source; | |
26 | reguser *rup; | |
27 | char userhost[USERLEN+HOSTLEN+2]; | |
e3805f60 P |
28 | maildomain *mdp, *smdp; |
29 | char *local; | |
bbc9e3a6 P |
30 | reguser *ruh; |
31 | int found=0; | |
32 | char *dupemail; | |
1dd6d55d | 33 | |
34 | if (getreguserfromnick(sender)) | |
35 | return CMD_ERROR; | |
36 | ||
37 | if (cargc<2) { | |
38 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "hello"); | |
39 | return CMD_ERROR; | |
40 | } | |
41 | ||
42 | if (findreguserbynick(sender->nick)) { | |
43 | chanservstdmessage(sender, QM_AUTHNAMEINUSE, sender->nick); | |
44 | return CMD_ERROR; | |
45 | } | |
46 | ||
47 | if (strcmp(cargv[0],cargv[1])) { | |
48 | chanservstdmessage(sender, QM_EMAILDONTMATCH); | |
49 | cs_log(sender,"HELLO FAIL username %s email don't match (%s vs %s)",sender->nick,cargv[0],cargv[1]); | |
50 | return CMD_ERROR; | |
51 | } | |
52 | ||
53 | if (csa_checkeboy(sender, cargv[0])) | |
54 | return CMD_ERROR; | |
55 | ||
dc9548f4 CP |
56 | if (csa_checkaccountname(sender, sender->nick)) |
57 | return CMD_ERROR; | |
58 | ||
e3805f60 P |
59 | mdp=findorcreatemaildomain(cargv[0]); |
60 | for(smdp=mdp; smdp; smdp=smdp->parent) { | |
61 | if((smdp->count >= smdp->limit) && (smdp->limit > 0)) { | |
62 | chanservstdmessage(sender, QM_DOMAINLIMIT); | |
63 | return CMD_ERROR; | |
64 | } | |
65 | } | |
66 | ||
bbc9e3a6 P |
67 | dupemail = strdup(cargv[0]); |
68 | local=strchr(dupemail, '@'); | |
e3805f60 P |
69 | *(local++)='\0'; |
70 | for (ruh=mdp->users; ruh; ruh=ruh->nextbydomain) { | |
71 | if (ruh->localpart) | |
72 | if (!match(local, ruh->localpart->content)) { | |
73 | found++; | |
74 | } | |
75 | } | |
c7970ab7 | 76 | free(dupemail); |
e3805f60 P |
77 | |
78 | if((found > mdp->actlimit) && (mdp->actlimit > 0)) { | |
79 | chanservstdmessage(sender, QM_DOMAINLIMIT); | |
80 | return CMD_ERROR; | |
81 | } | |
82 | ||
1dd6d55d | 83 | rup=getreguser(); |
84 | rup->status=0; | |
85 | rup->ID=++lastuserID; | |
86 | strncpy(rup->username,sender->nick,NICKLEN); rup->username[NICKLEN]='\0'; | |
87 | rup->created=time(NULL); | |
cf50e022 | 88 | rup->lastauth=0; |
1dd6d55d | 89 | rup->lastemailchange=time(NULL); |
90 | rup->flags=QUFLAG_NOTICE; | |
91 | rup->languageid=0; | |
92 | rup->suspendby=0; | |
93 | rup->suspendexp=0; | |
94 | rup->password[0]='\0'; | |
1dd6d55d | 95 | rup->email=getsstring(cargv[0],EMAILLEN); |
e3805f60 P |
96 | rup->localpart=getsstring(local,EMAILLEN); |
97 | rup->domain=mdp; | |
98 | addregusertomaildomain(rup, rup->domain); | |
1dd6d55d | 99 | rup->info=NULL; |
100 | sprintf(userhost,"%s@%s",sender->ident,sender->host->name->content); | |
101 | rup->lastuserhost=getsstring(userhost,USERLEN+HOSTLEN+1); | |
102 | rup->suspendreason=NULL; | |
103 | rup->comment=NULL; | |
104 | rup->knownon=NULL; | |
105 | rup->checkshd=NULL; | |
106 | rup->stealcount=0; | |
107 | rup->fakeuser=NULL; | |
1dd6d55d | 108 | addregusertohash(rup); |
109 | csa_createrandompw(rup->password, PASSLEN); | |
1dd6d55d | 110 | chanservstdmessage(sender, QM_NEWACCOUNT, rup->username,rup->email->content); |
111 | cs_log(sender,"HELLO OK created auth %s (%s)",rup->username,rup->email->content); | |
112 | csdb_createuser(rup); | |
113 | csdb_createmail(rup, QMAIL_NEWACCOUNT); | |
114 | ||
115 | return CMD_OK; | |
116 | } |