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