]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: requestpassword | |
5 | * CMDLEVEL: QCMD_NOTAUTHED | |
b7ae0f2c | 6 | * CMDARGS: 1 |
1dd6d55d | 7 | * CMDDESC: Requests the current password by email. |
8 | * CMDFUNC: csa_doreqpw | |
9 | * CMDPROTO: int csa_doreqpw(void *source, int cargc, char **cargv); | |
b7ae0f2c | 10 | * CMDHELP: Usage: REQUESTPASSWORD <email> |
50cd26d6 | 11 | * CMDHELP: Sends your current password to your registered email address, where: |
50cd26d6 | 12 | * CMDHELP: email - your registered email address |
1dd6d55d | 13 | */ |
14 | ||
15 | #include "../chanserv.h" | |
16 | #include "../authlib.h" | |
17 | #include "../../lib/irc_string.h" | |
18 | #include <stdio.h> | |
19 | #include <string.h> | |
20 | ||
21 | int csa_doreqpw(void *source, int cargc, char **cargv) { | |
22 | reguser *rup; | |
23 | nick *sender=source; | |
b7ae0f2c | 24 | int i, matched = 0; |
1dd6d55d | 25 | |
b7ae0f2c | 26 | if (cargc<1) { |
1dd6d55d | 27 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "requestpassword"); |
28 | return CMD_ERROR; | |
29 | } | |
30 | ||
b7ae0f2c CP |
31 | for (i=0;i<REGUSERHASHSIZE;i++) { |
32 | for (rup=regusernicktable[i];rup;rup=rup->nextbyname) { | |
33 | if(!rup->email || strcasecmp(cargv[0],rup->email->content)) | |
34 | continue; | |
1dd6d55d | 35 | |
b7ae0f2c CP |
36 | if(UHasHelperPriv(rup)) { |
37 | cs_log(sender,"REQUESTPASSWORD FAIL privileged email %s",cargv[0]); | |
38 | continue; | |
39 | } | |
a03c04b3 | 40 | |
b7ae0f2c | 41 | matched = 1; |
1dd6d55d | 42 | |
b7ae0f2c CP |
43 | if(csa_checkthrottled(sender, rup, "REQUESTPASSWORD")) |
44 | continue; | |
45 | ||
46 | rup->lastemailchange=time(NULL); | |
47 | csdb_updateuser(rup); | |
1dd6d55d | 48 | |
b7ae0f2c CP |
49 | if(rup->lastauth) { |
50 | csdb_createmail(rup, QMAIL_REQPW); | |
51 | } else { | |
52 | csdb_createmail(rup, QMAIL_NEWACCOUNT); /* user hasn't authed yet and needs to do the captcha */ | |
53 | } | |
cf50e022 | 54 | |
b7ae0f2c CP |
55 | cs_log(sender,"REQUESTPASSWORD OK username %s email %s", rup->username,rup->email->content); |
56 | chanservstdmessage(sender, QM_MAILQUEUED); | |
57 | } | |
58 | } | |
59 | ||
60 | if(!matched) { | |
61 | cs_log(sender,"REQUESTPASSWORD FAIL email %s",cargv[0]); | |
62 | chanservstdmessage(sender, QM_BADEMAIL); | |
63 | return CMD_ERROR; | |
cf50e022 | 64 | } else { |
b7ae0f2c | 65 | chanservstdmessage(sender, QM_DONE); |
cf50e022 | 66 | } |
1dd6d55d | 67 | |
68 | return CMD_OK; | |
69 | } |