]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/authcmds/challengeauth.c
email and newpass should be secure commands.
[irc/quakenet/newserv.git] / chanserv / authcmds / challengeauth.c
1 /* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: challengeauth
5 * CMDLEVEL: QCMD_SECURE | QCMD_NOTAUTHED
6 * CMDARGS: 3
7 * CMDDESC: Authenticates you on the bot using challenge response.
8 * CMDFUNC: csa_dochallengeauth
9 * CMDPROTO: int csa_dochallengeauth(void *source, int cargc, char **cargv);
10 */
11
12 #include "../chanserv.h"
13 #include <time.h>
14
15 int csa_auth(void *source, int cargc, char **cargv, CRAlgorithm alg);
16
17 int csa_dochallengeauth(void *source, int cargc, char **cargv) {
18 CRAlgorithm alg;
19 activeuser* aup;
20 time_t t;
21 nick *sender=(nick *)source;
22
23 if(cargc<3) {
24 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "challengeauth");
25 return CMD_ERROR;
26 }
27
28 if (!(aup=getactiveuserfromnick(sender)))
29 return CMD_ERROR;
30
31 t = time(NULL);
32 if(t > aup->entropyttl) {
33 chanservstdmessage(sender, QM_NOCHALLENGE);
34 return CMD_ERROR;
35 }
36
37 aup->entropyttl = 0;
38
39 alg = cs_cralgorithm(cargv[2]);
40 if(!alg) {
41 chanservstdmessage(sender, QM_CHALLENGEBADALGORITHM);
42 return CMD_ERROR;
43 }
44
45 return csa_auth(sender, cargc, cargv, alg);
46 }