]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/authcmds/email.c
1 /* Automatically generated by refactor.pl.
4 * CMDLEVEL: QCMD_SECURE | QCMD_AUTHED
6 * CMDDESC: Change your email address.
8 * CMDPROTO: int csa_doemail(void *source, int cargc, char **cargv);
9 * CMDHELP: Usage: EMAIL <password> <email> <email>
10 * CMDHELP: Changes your register email address. Confirmation of the change will be sent
11 * CMDHELP: both old and new addresses. Where:
12 * CMDHELP: password - your password
13 * CMDHELP: email - new email address. Must be entered exactly the same way twice to avoid
15 * CMDHELP: Note: due to the sensitive nature of this command, you must send the message
16 * CMDHELP: to Q@CServe.quakenet.org when using it.
19 #include "../chanserv.h"
20 #include "../authlib.h"
21 #include "../../lib/irc_string.h"
25 int csa_doemail(void *source
, int cargc
, char **cargv
) {
28 maildomain
*mdp
, *smdp
;
32 time_t t
= time(NULL
);
36 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "email");
40 if (!(rup
=getreguserfromnick(sender
)))
43 if (!checkpassword(rup
, cargv
[0])) {
44 chanservstdmessage(sender
, QM_AUTHFAIL
);
45 cs_log(sender
,"EMAIL FAIL username %s bad password %s",rup
->username
,cargv
[0]);
49 if (strcmp(cargv
[1],cargv
[2])) {
50 chanservstdmessage(sender
, QM_EMAILDONTMATCH
);
51 cs_log(sender
,"EMAIL FAIL username %s email don't match (%s vs %s)",rup
->username
,cargv
[1],cargv
[2]);
55 if(!UHasHelperPriv(rup
) && (rup
->lockuntil
&& rup
->lockuntil
> t
)) {
56 chanservstdmessage(sender
, QM_ACCOUNTLOCKED
, rup
->lockuntil
);
60 if(rup
->email
&& !strcasecmp(cargv
[1], rup
->email
->content
)) {
61 chanservstdmessage(sender
, QM_EMAILMATCHESOLD
);
65 if (csa_checkeboy(sender
, cargv
[1]))
68 for(mlp
=maillocks
;mlp
;mlp
=mlp
->next
) {
69 if(!match(mlp
->pattern
->content
, cargv
[1])) {
70 chanservstdmessage(sender
, QM_MAILLOCKED
);
75 dupemail
= strdup(cargv
[1]);
76 local
=strchr(dupemail
, '@');
81 mdp
=findnearestmaildomain(local
);
83 for(smdp
=mdp
; smdp
; smdp
=smdp
->parent
) {
84 if(MDIsBanned(smdp
)) {
86 chanservstdmessage(sender
, QM_MAILLOCKED
);
89 if((smdp
->count
>= smdp
->limit
) && (smdp
->limit
> 0)) {
91 chanservstdmessage(sender
, QM_DOMAINLIMIT
);
97 mdp
=findmaildomainbydomain(local
);
99 for (ruh
=mdp
->users
; ruh
; ruh
=ruh
->nextbydomain
) {
101 if (!strcasecmp(dupemail
, ruh
->localpart
->content
)) {
106 if((found
>= mdp
->actlimit
) && (mdp
->actlimit
> 0)) {
108 chanservstdmessage(sender
, QM_ADDRESSLIMIT
);
113 mdp
=findorcreatemaildomain(cargv
[1]);
115 csdb_createmail(rup
, QMAIL_NEWEMAIL
);
116 csdb_accounthistory_insert(sender
, NULL
, NULL
, rup
->email
?rup
->email
->content
:NULL
, cargv
[1]);
117 delreguserfrommaildomain(rup
,rup
->domain
);
120 freesstring(rup
->lastemail
);
121 rup
->lastemail
=rup
->email
;
122 rup
->email
=getsstring(cargv
[1],EMAILLEN
);
123 rup
->lastemailchange
=t
;
124 rup
->domain
=findorcreatemaildomain(rup
->email
->content
);
125 if(!UHasHelperPriv(rup
)) {
126 rup
->lockuntil
=t
+7*24*3600;
130 addregusertomaildomain(rup
, rup
->domain
);
133 rup
->localpart
=getsstring(dupemail
,EMAILLEN
);
139 chanservstdmessage(sender
, QM_EMAILCHANGED
, cargv
[1]);
140 cs_log(sender
,"EMAIL OK username %s",rup
->username
);
142 #ifdef AUTHGATE_WARNINGS
143 if(UHasOperPriv(rup
))
144 chanservsendmessage(sender
, "WARNING FOR PRIVILEGED USERS: you MUST go to https://auth.quakenet.org and login successfully to update the cache.");
147 csdb_updateuser(rup
);