]>
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"
29 int csa_donewpw ( void * source
, int cargc
, char ** cargv
) {
32 int i
, cntweak
= 0 , cntdigits
= 0 , cntletters
= 0 ;
36 chanservstdmessage ( sender
, QM_NOTENOUGHPARAMS
, "newpass" );
40 if (!( rup
= getreguserfromnick ( sender
)))
43 if (! checkpassword ( rup
, cargv
[ 0 ])) {
44 chanservstdmessage ( sender
, QM_AUTHFAIL
);
45 cs_log ( sender
, "NEWPASS FAIL username %s bad password %s " , rup
-> username
, cargv
[ 0 ]);
49 if ( strcmp ( cargv
[ 1 ], cargv
[ 2 ])) {
50 chanservstdmessage ( sender
, QM_PWDONTMATCH
); /* Sorry, passwords do not match */
51 cs_log ( sender
, "NEWPASS FAIL username %s new passwords don't match ( %s vs %s )" , rup
-> username
, cargv
[ 1 ], cargv
[ 2 ]);
55 if ( strlen ( cargv
[ 1 ]) < 6 ) {
56 chanservstdmessage ( sender
, QM_PWTOSHORT
); /* new password to short */
57 cs_log ( sender
, "NEWPASS FAIL username %s password to short %s ( %z u characters)" , rup
-> username
, cargv
[ 1 ], strlen ( cargv
[ 1 ]));
61 for ( i
= 0 ; cargv
[ 1 ][ i
] && i
< PASSLEN
; i
++ ) {
62 if ( cargv
[ 1 ][ i
] == cargv
[ 1 ][ i
+ 1 ] || cargv
[ 1 ][ i
] + 1 == cargv
[ 1 ][ i
+ 1 ] || cargv
[ 1 ][ i
] - 1 == cargv
[ 1 ][ i
+ 1 ] )
64 if ( isdigit ( cargv
[ 1 ][ i
]))
66 if ( islower ( cargv
[ 1 ][ i
]) || isupper ( cargv
[ 1 ][ i
]))
70 if ( cntweak
> 3 || ! cntdigits
|| ! cntletters
) {
71 chanservstdmessage ( sender
, QM_PWTOWEAK
); /* new password is weak */
72 cs_log ( sender
, "NEWPASS FAIL username %s password to weak %s " , rup
-> username
, cargv
[ 1 ]);
77 if (! UHasStaffPriv ( rup
)) {
78 if ( rup
-> lockuntil
&& rup
-> lockuntil
> t
) {
79 chanservstdmessage ( sender
, QM_ACCOUNTLOCKED
, rup
-> lockuntil
);
82 rup
-> lockuntil
= t
+ 7 * 24 * 3600 ;
88 freesstring ( rup
-> lastemail
);
92 rup
-> lastpasschange
= t
;
93 csdb_accounthistory_insert ( sender
, rup
-> password
, cargv
[ 1 ], NULL
, NULL
);
94 setpassword ( rup
, cargv
[ 1 ]);
96 rup
-> lastauth
= time ( NULL
);
97 chanservstdmessage ( sender
, QM_PWCHANGED
);
98 cs_log ( sender
, "NEWPASS OK username %s " , rup
-> username
);
100 #ifdef AUTHGATE_WARNINGS
101 if ( UHasOperPriv ( rup
))
102 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." );
105 csdb_updateuser ( rup
);
106 csdb_createmail ( rup
, QMAIL_NEWPW
);