]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/authcmds/newpass.c
1 /* Automatically generated by refactor.pl.
5 * CMDALIASES: newpassword
6 * CMDLEVEL: QCMD_SECURE | QCMD_AUTHED
8 * CMDDESC: Change your password.
10 * CMDPROTO: int csa_donewpw(void *source, int cargc, char **cargv);
11 * CMDHELP: Usage: @UCOMMAND@ <oldpassword> <newpassword> <newpassword>
12 * CMDHELP: Changes your account password. Your new password must be at least 6 characters
13 * CMDHELP: long, contain at least one number and one letter, and may not contain sequences
14 * CMDHELP: of letters or numbers. Your new password will be sent to your registered email
15 * CMDHELP: address. Where:
16 * CMDHELP: oldpassword - your existing account password
17 * CMDHELP: newpassword - your desired new password. Must be entered the same both times.
18 * CMDHELP: Note: due to the sensitive nature of this command, you must send the message to
19 * CMDHELP: Q@CServe.quakenet.org when using it.
22 #include "../chanserv.h"
23 #include "../authlib.h"
24 #include "../../lib/irc_string.h"
25 #include "../../core/hooks.h"
30 int csa_donewpw ( void * source
, int cargc
, char ** cargv
) {
38 chanservstdmessage ( sender
, QM_NOTENOUGHPARAMS
, "newpass" );
42 if (!( rup
= getreguserfromnick ( sender
)))
45 if (! checkpassword ( rup
, cargv
[ 0 ])) {
46 chanservstdmessage ( sender
, QM_AUTHFAIL
);
47 cs_log ( sender
, "NEWPASS FAIL username %s bad password %s " , rup
-> username
, cargv
[ 0 ]);
51 if ( strcmp ( cargv
[ 1 ], cargv
[ 2 ])) {
52 chanservstdmessage ( sender
, QM_PWDONTMATCH
); /* Sorry, passwords do not match */
53 cs_log ( sender
, "NEWPASS FAIL username %s new passwords don't match ( %s vs %s )" , rup
-> username
, cargv
[ 1 ], cargv
[ 2 ]);
57 if (! strcmp ( cargv
[ 0 ], cargv
[ 1 ])) {
58 /* If they are the same then continue anyway but don't send the hook later. */
62 pq
= csa_checkpasswordquality ( cargv
[ 1 ]);
63 if ( pq
== QM_PWTOSHORT
) {
64 chanservstdmessage ( sender
, QM_PWTOSHORT
); /* new password to short */
65 cs_log ( sender
, "NEWPASS FAIL username %s password to short %s ( %z u characters)" , rup
-> username
, cargv
[ 1 ], strlen ( cargv
[ 1 ]));
67 } else if ( pq
== QM_PWTOWEAK
) {
68 chanservstdmessage ( sender
, QM_PWTOWEAK
); /* new password is weak */
69 cs_log ( sender
, "NEWPASS FAIL username %s password to weak %s " , rup
-> username
, cargv
[ 1 ]);
74 chanservsendmessage ( sender
, "unknown error in newpass.c... contact #help" );
79 if (! UHasStaffPriv ( rup
)) {
80 if ( rup
-> lockuntil
&& rup
-> lockuntil
> t
) {
81 chanservstdmessage ( sender
, QM_ACCOUNTLOCKED
, rup
-> lockuntil
);
84 rup
-> lockuntil
= t
+ 7 * 24 * 3600 ;
90 freesstring ( rup
-> lastemail
);
94 rup
-> lastpasschange
= t
;
95 csdb_accounthistory_insert ( sender
, rup
-> password
, cargv
[ 1 ], NULL
, NULL
);
96 setpassword ( rup
, cargv
[ 1 ]);
98 rup
-> lastauth
= time ( NULL
);
99 chanservstdmessage ( sender
, QM_PWCHANGED
);
100 cs_log ( sender
, "NEWPASS OK username %s " , rup
-> username
);
102 #ifdef AUTHGATE_WARNINGS
103 if ( UHasOperPriv ( rup
))
104 chanservsendmessage ( sender
, "WARNING FOR PRIVILEGED USERS: you MUST go to https://auth.quakenet.org and login successfully to update the cache, if you do not your old password will still be usable in certain circumstances." );
107 csdb_updateuser ( rup
);
108 csdb_createmail ( rup
, QMAIL_NEWPW
);
111 triggerhook ( HOOK_CHANSERV_PWCHANGE
, sender
);