]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: setpassword | |
d353effa | 5 | * CMDALIASES: setpass |
1dd6d55d | 6 | * CMDLEVEL: QCMD_OPER |
7 | * CMDARGS: 2 | |
8 | * CMDDESC: Set a new password. | |
9 | * CMDFUNC: csa_dosetpw | |
10 | * CMDPROTO: int csa_dosetpw(void *source, int cargc, char **cargv); | |
d353effa | 11 | * CMDHELP: Usage: @UCOMMAND@ <username> <password> |
85174237 | 12 | * CMDHELP: Sets the password for the specified username. |
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_dosetpw(void *source, int cargc, char **cargv) { | |
1dd6d55d | 22 | nick *sender=source; |
1232a729 | 23 | reguser *rup, *vrup=getreguserfromnick(sender); |
1dd6d55d | 24 | |
25 | if (cargc<2) { | |
26 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "setpassword"); | |
27 | return CMD_ERROR; | |
28 | } | |
29 | ||
30 | if (!(rup=findreguser(sender, cargv[0]))) | |
31 | return CMD_ERROR; | |
32 | ||
1232a729 CP |
33 | if(UHasHelperPriv(rup)) { |
34 | cs_log(sender,"GETPASSWORD FAILED username %s",rup->username); | |
35 | chanservwallmessage("%s (%s) just FAILED using SETPASSWORD on %s", sender->nick, vrup->username, rup->username); | |
36 | chanservsendmessage(sender, "Sorry, that user is privileged."); | |
37 | return CMD_ERROR; | |
38 | } | |
39 | ||
40 | cs_log(sender,"SETPASSWORD OK username %s",rup->username); | |
41 | chanservwallmessage("%s (%s) just used SETPASSWORD on %s", sender->nick, vrup->username, rup->username); | |
42 | ||
30a66d6c CP |
43 | if(rup->lastemail) { |
44 | freesstring(rup->lastemail); | |
45 | rup->lastemail=NULL; | |
46 | } | |
47 | rup->lockuntil=0; | |
0f32b411 CP |
48 | |
49 | csdb_accounthistory_insert(sender, rup->password, cargv[1], NULL, NULL); | |
50 | setpassword(rup, cargv[1]); | |
1dd6d55d | 51 | csdb_updateuser(rup); |
52 | ||
1232a729 CP |
53 | chanservstdmessage(sender, QM_PWCHANGED); |
54 | ||
1dd6d55d | 55 | return CMD_OK; |
56 | } |