]>
Commit | Line | Data |
---|---|---|
30a66d6c CP |
1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: reset | |
5 | * CMDLEVEL: QCMD_NOTAUTHED | |
6 | * CMDARGS: 2 | |
7 | * CMDDESC: Restores the old details on an account after a change. | |
8 | * CMDFUNC: csa_doreset | |
9 | * CMDPROTO: int csa_doreset(void *source, int cargc, char **cargv); | |
10 | * CMDHELP: Usage: RESET <username> <code> | |
11 | * CMDHELP: Restores your old email address and password if any of these | |
12 | * CMDHELP: have recently changed, where the following parameters are: | |
13 | * CMDHELP: username - your username | |
14 | * CMDHELP: code - the code received in the RESET email. | |
15 | */ | |
16 | ||
17 | #include "../chanserv.h" | |
18 | #include "../authlib.h" | |
19 | #include "../../lib/irc_string.h" | |
20 | #include <stdio.h> | |
21 | #include <string.h> | |
22 | ||
23 | int csa_doreset(void *source, int cargc, char **cargv) { | |
24 | reguser *rup; | |
25 | nick *sender=source; | |
26 | ||
27 | if (cargc<2) { | |
28 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "reset"); | |
29 | return CMD_ERROR; | |
30 | } | |
31 | ||
32 | if (!(rup=findreguser(sender, cargv[0]))) | |
33 | return CMD_ERROR; | |
34 | ||
59687380 | 35 | if(UHasHelperPriv(rup) || (!rup->lockuntil || rup->lockuntil <= time(NULL))) { |
30a66d6c CP |
36 | chanservstdmessage(sender, QM_ACCOUNTNOTLOCKED); |
37 | return CMD_ERROR; | |
38 | } | |
39 | ||
40 | if(strcasecmp(cargv[1], csc_generateresetcode(rup->lockuntil, rup->username))) { | |
41 | chanservstdmessage(sender, QM_BADRESETCODE); | |
42 | return CMD_ERROR; | |
43 | } | |
44 | ||
45 | if(rup->lastemail) { | |
46 | if(rup->email) | |
47 | freesstring(rup->email); | |
48 | rup->email=rup->lastemail; | |
49 | rup->lastemail=NULL; | |
50 | } | |
51 | ||
52 | csa_createrandompw(rup->password, PASSLEN); | |
53 | rup->lockuntil=0; | |
54 | cs_log(sender,"RESET OK username %s", rup->username); | |
55 | csdb_updateuser(rup); | |
56 | csdb_createmail(rup, QMAIL_RESET); | |
57 | chanservstdmessage(sender, QM_RESETOK); | |
58 | ||
59 | return CMD_OK; | |
60 | } |