]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/authcmds/reset.c
1 /* Automatically generated by refactor.pl.
5 * CMDLEVEL: QCMD_NOTAUTHED
7 * CMDDESC: Restores the old details on an account after a change.
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.
17 #include "../chanserv.h"
18 #include "../authlib.h"
19 #include "../../lib/irc_string.h"
23 int csa_doreset(void *source
, int cargc
, char **cargv
) {
26 char newpassword
[PASSLEN
+1];
29 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "reset");
33 if (!(rup
=findreguser(sender
, cargv
[0])))
36 if(UHasHelperPriv(rup
) || (!rup
->lockuntil
|| rup
->lockuntil
<= time(NULL
))) {
37 chanservstdmessage(sender
, QM_ACCOUNTNOTLOCKED
);
41 if(strcasecmp(cargv
[1], csc_generateresetcode(rup
->lockuntil
, rup
->username
))) {
42 chanservstdmessage(sender
, QM_BADRESETCODE
);
46 csa_createrandompw(newpassword
, PASSLEN
);
49 csdb_accounthistory_insert(sender
, rup
->password
, newpassword
, rup
->email
?rup
->email
->content
:NULL
, rup
->lastemail
->content
);
51 freesstring(rup
->email
);
52 rup
->email
=rup
->lastemail
;
55 csdb_accounthistory_insert(sender
, rup
->password
, newpassword
, NULL
, NULL
);
58 setpassword(rup
, newpassword
);
61 cs_log(sender
,"RESET OK username %s", rup
->username
);
63 csdb_createmail(rup
, QMAIL_RESET
);
64 chanservstdmessage(sender
, QM_RESETOK
);