]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
1dd6d55d | 2 | * |
3 | * CMDNAME: email | |
bace4964 | 4 | * CMDLEVEL: QCMD_SECURE | QCMD_AUTHED |
1dd6d55d | 5 | * CMDARGS: 3 |
6 | * CMDDESC: Change your email address. | |
7 | * CMDFUNC: csa_doemail | |
8 | * CMDPROTO: int csa_doemail(void *source, int cargc, char **cargv); | |
50cd26d6 | 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 | |
14 | * CMDHELP: mistakes. | |
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. | |
1dd6d55d | 17 | */ |
18 | ||
19 | #include "../chanserv.h" | |
20 | #include "../authlib.h" | |
21 | #include "../../lib/irc_string.h" | |
22 | #include <stdio.h> | |
23 | #include <string.h> | |
24 | ||
25 | int csa_doemail(void *source, int cargc, char **cargv) { | |
26 | reguser *rup; | |
27 | nick *sender=source; | |
e3805f60 P |
28 | maildomain *mdp, *smdp; |
29 | char *local; | |
bbc9e3a6 | 30 | char *dupemail; |
1dd6d55d | 31 | |
32 | if (cargc<3) { | |
33 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "email"); | |
34 | return CMD_ERROR; | |
35 | } | |
36 | ||
37 | if (!(rup=getreguserfromnick(sender))) | |
38 | return CMD_ERROR; | |
39 | ||
2271ea8c | 40 | if (!checkpassword(rup, cargv[0])) { |
1dd6d55d | 41 | chanservstdmessage(sender, QM_AUTHFAIL); |
2271ea8c | 42 | cs_log(sender,"EMAIL FAIL username %s bad password %s",rup->username,cargv[0]); |
1dd6d55d | 43 | return CMD_ERROR; |
44 | } | |
45 | ||
46 | if (strcmp(cargv[1],cargv[2])) { | |
47 | chanservstdmessage(sender, QM_EMAILDONTMATCH); | |
48 | cs_log(sender,"EMAIL FAIL username %s email don't match (%s vs %s)",rup->username,cargv[1],cargv[2]); | |
49 | return CMD_ERROR; | |
50 | } | |
51 | ||
52 | if (csa_checkeboy(sender, cargv[1])) | |
53 | return CMD_ERROR; | |
54 | ||
e3805f60 P |
55 | mdp=findorcreatemaildomain(cargv[1]); |
56 | for(smdp=mdp; smdp; smdp=smdp->parent) { | |
57 | if((smdp->count >= smdp->limit) && (smdp->limit > 0)) { | |
58 | chanservstdmessage(sender, QM_DOMAINLIMIT); | |
59 | return CMD_ERROR; | |
60 | } | |
61 | } | |
1dd6d55d | 62 | |
63 | csdb_createmail(rup, QMAIL_NEWEMAIL); | |
183b8e2f | 64 | csdb_accounthistory_insert(sender, NULL, NULL, rup->email, getsstring(cargv[1], EMAILLEN)); |
e3805f60 | 65 | delreguserfrommaildomain(rup,rup->domain); |
1dd6d55d | 66 | freesstring(rup->email); |
67 | rup->email=getsstring(cargv[1],EMAILLEN); | |
68 | rup->lastemailchange=time(NULL); | |
e3805f60 P |
69 | rup->domain=findorcreatemaildomain(rup->email->content); |
70 | addregusertomaildomain(rup, rup->domain); | |
bbc9e3a6 | 71 | dupemail = strdup(rup->email->content); |
80d2de64 | 72 | if((local=strchr(dupemail, '@'))) { |
e3805f60 P |
73 | *(local++)='\0'; |
74 | rup->localpart=getsstring(local,EMAILLEN); | |
75 | } else { | |
76 | rup->localpart=NULL; | |
77 | } | |
c7970ab7 P |
78 | free(dupemail); |
79 | ||
1dd6d55d | 80 | chanservstdmessage(sender, QM_EMAILCHANGED, cargv[1]); |
81 | cs_log(sender,"EMAIL OK username %s",rup->username); | |
82 | csdb_updateuser(rup); | |
83 | ||
84 | return CMD_OK; | |
85 | } |