]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/authcmds/hello.c
1 /* Automatically generated by refactor.pl.
5 * CMDLEVEL: QCMD_NOTAUTHED
7 * CMDDESC: Creates a new user account.
9 * CMDPROTO: int csa_dohello(void *source, int cargc, char **cargv);
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.
18 #include "../chanserv.h"
19 #include "../authlib.h"
20 #include "../../lib/irc_string.h"
24 int csa_dohello(void *source
, int cargc
, char **cargv
) {
27 char userhost
[USERLEN
+HOSTLEN
+2];
28 maildomain
*mdp
, *smdp
;
36 if (getreguserfromnick(sender
))
40 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "hello");
44 if (findreguserbynick(sender
->nick
)) {
45 chanservstdmessage(sender
, QM_AUTHNAMEINUSE
, sender
->nick
);
49 if (!(aup
= getactiveuserfromnick(sender
)))
52 if (aup
->helloattempts
> MAXHELLOS
) {
53 chanservstdmessage(sender
, QM_MAXHELLOLIMIT
);
57 if (strcmp(cargv
[0],cargv
[1])) {
58 chanservstdmessage(sender
, QM_EMAILDONTMATCH
);
59 cs_log(sender
,"HELLO FAIL username %s email don't match (%s vs %s)",sender
->nick
,cargv
[0],cargv
[1]);
63 if (csa_checkeboy(sender
, cargv
[0]))
66 if (csa_checkaccountname(sender
, sender
->nick
))
69 for(mlp
=maillocks
;mlp
;mlp
=mlp
->next
) {
70 if(!match(mlp
->pattern
->content
, cargv
[0])) {
71 chanservstdmessage(sender
, QM_MAILLOCKED
);
76 dupemail
= strdup(cargv
[0]);
77 local
=strchr(dupemail
, '@');
84 mdp
=findnearestmaildomain(local
);
86 for(smdp
=mdp
; smdp
; smdp
=smdp
->parent
) {
87 if(MDIsBanned(smdp
)) {
89 chanservstdmessage(sender
, QM_MAILLOCKED
);
92 if((smdp
->count
>= smdp
->limit
) && (smdp
->limit
> 0)) {
94 chanservstdmessage(sender
, QM_DOMAINLIMIT
);
100 mdp
=findmaildomainbydomain(local
);
102 for (ruh
=mdp
->users
; ruh
; ruh
=ruh
->nextbydomain
) {
104 if (!strcasecmp(dupemail
, ruh
->localpart
->content
)) {
109 if((found
>= mdp
->actlimit
) && (mdp
->actlimit
> 0)) {
111 chanservstdmessage(sender
, QM_ADDRESSLIMIT
);
118 aup
->helloattempts
++;
120 rup
=csa_createaccount(sender
->nick
,"", cargv
[0]);
121 csa_createrandompw(rup
->password
, PASSLEN
);
122 sprintf(userhost
,"%s@%s",sender
->ident
,sender
->host
->name
->content
);
123 rup
->lastuserhost
=getsstring(userhost
,USERLEN
+HOSTLEN
+1);
125 chanservstdmessage(sender
, QM_NEWACCOUNT
, rup
->username
,rup
->email
->content
);
126 cs_log(sender
,"HELLO OK created auth %s (%s)",rup
->username
,rup
->email
->content
);
127 csdb_createuser(rup
);
128 csdb_createmail(rup
, QMAIL_NEWACCOUNT
);