]>
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 /* REMEMBER YOU CAN ALSO CREATE ACCOUNTS IN CHANSERV_RELAY.C */
25 int csa_dohello(void *source
, int cargc
, char **cargv
) {
28 char userhost
[USERLEN
+HOSTLEN
+2];
29 maildomain
*mdp
, *smdp
;
38 if (getreguserfromnick(sender
))
42 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "hello");
46 if (findreguserbynick(sender
->nick
)) {
47 chanservstdmessage(sender
, QM_AUTHNAMEINUSE
, sender
->nick
);
51 if (!(aup
= getactiveuserfromnick(sender
)))
54 if (aup
->helloattempts
> MAXHELLOS
) {
55 chanservstdmessage(sender
, QM_MAXHELLOLIMIT
);
59 if (strcmp(cargv
[0],cargv
[1])) {
60 chanservstdmessage(sender
, QM_EMAILDONTMATCH
);
61 cs_log(sender
,"HELLO FAIL username %s email don't match (%s vs %s)",sender
->nick
,cargv
[0],cargv
[1]);
65 if (csa_checkeboy(sender
, cargv
[0]))
68 if (csa_checkaccountname(sender
, sender
->nick
))
71 for(mlp
=maillocks
;mlp
;mlp
=mlp
->next
) {
72 if(!match(mlp
->pattern
->content
, cargv
[0])) {
73 chanservstdmessage(sender
, QM_MAILLOCKED
);
78 dupemail
= strdup(cargv
[0]);
79 local
=strchr(dupemail
, '@');
86 mdp
=findnearestmaildomain(local
);
88 for(smdp
=mdp
; smdp
; smdp
=smdp
->parent
) {
89 if(MDIsBanned(smdp
)) {
91 chanservstdmessage(sender
, QM_MAILLOCKED
);
94 if((smdp
->count
>= smdp
->limit
) && (smdp
->limit
> 0)) {
96 chanservstdmessage(sender
, QM_DOMAINLIMIT
);
102 mdp
=findmaildomainbydomain(local
);
104 for (ruh
=mdp
->users
; ruh
; ruh
=ruh
->nextbydomain
) {
106 if (!strcasecmp(dupemail
, ruh
->localpart
->content
)) {
111 if((found
>= mdp
->actlimit
) && (mdp
->actlimit
> 0)) {
113 chanservstdmessage(sender
, QM_ADDRESSLIMIT
);
118 mdp
=findorcreatemaildomain(cargv
[0]);
120 aup
->helloattempts
++;
122 /* REMEMBER YOU CAN ALSO CREATE ACCOUNTS IN CHANSERV_RELAY.C */
123 /* REMEMBER YOU CAN ALSO CREATE ACCOUNTS IN CHANSERV_RELAY.C */
124 /* REMEMBER YOU CAN ALSO CREATE ACCOUNTS IN CHANSERV_RELAY.C */
129 rup
->ID
=++lastuserID
;
130 strncpy(rup
->username
,sender
->nick
,NICKLEN
); rup
->username
[NICKLEN
]='\0';
133 rup
->lastemailchange
=t
;
134 rup
->lastpasschange
=t
;
135 rup
->flags
=QUFLAG_NOTICE
;
141 rup
->password
[0]='\0';
142 rup
->email
=getsstring(cargv
[0],EMAILLEN
);
145 rup
->localpart
=getsstring(dupemail
,EMAILLEN
);
149 addregusertomaildomain(rup
, rup
->domain
);
151 sprintf(userhost
,"%s@%s",sender
->ident
,sender
->host
->name
->content
);
152 rup
->lastuserhost
=getsstring(userhost
,USERLEN
+HOSTLEN
+1);
153 rup
->suspendreason
=NULL
;
159 addregusertohash(rup
);
160 csa_createrandompw(rup
->password
, PASSLEN
);
161 chanservstdmessage(sender
, QM_NEWACCOUNT
, rup
->username
,rup
->email
->content
);
162 cs_log(sender
,"HELLO OK created auth %s (%s)",rup
->username
,rup
->email
->content
);
163 csdb_createuser(rup
);
164 csdb_createmail(rup
, QMAIL_NEWACCOUNT
);