]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/authcmds/newpass.c
4075fcf1fcd22179a5f4da823baddb31e8a8ff6e
1 /* Automatically generated by refactor.pl.
5 * CMDLEVEL: QCMD_SECURE | QCMD_AUTHED
7 * CMDDESC: Change your password.
9 * CMDPROTO: int csa_donewpw(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: NEWPASS <oldpassword> <newpassword> <newpassword>
11 * CMDHELP: Changes your account password. Your new password must be at least 6 characters
12 * CMDHELP: long, contain at least one number and one letter, and may not contain sequences
13 * CMDHELP: of letters or numbers. Your new password will be sent to your registered email
14 * CMDHELP: address. Where:
15 * CMDHELP: oldpassword - your existing account password
16 * CMDHELP: newpassword - your desired new password. Must be entered the same both times.
17 * CMDHELP: Note: due to the sensitive nature of this command, you must send the message to
18 * CMDHELP: Q@CServe.quakenet.org when using it.
21 #include "../chanserv.h"
22 #include "../authlib.h"
23 #include "../../lib/irc_string.h"
28 int csa_donewpw(void *source
, int cargc
, char **cargv
) {
31 int i
, cntweak
= 0, cntdigits
= 0, cntletters
= 0;
35 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "newpass");
39 if (!(rup
=getreguserfromnick(sender
)))
42 if (!checkpassword(rup
, cargv
[0])) {
43 chanservstdmessage(sender
, QM_AUTHFAIL
);
44 cs_log(sender
,"NEWPASS FAIL username %s bad password %s",rup
->username
,cargv
[0]);
48 if (strcmp(cargv
[1],cargv
[2])) {
49 chanservstdmessage(sender
, QM_PWDONTMATCH
); /* Sorry, passwords do not match */
50 cs_log(sender
,"NEWPASS FAIL username %s new passwords don't match (%s vs %s)",rup
->username
,cargv
[1],cargv
[2]);
54 if (strlen(cargv
[1]) < 6) {
55 chanservstdmessage(sender
, QM_PWTOSHORT
); /* new password to short */
56 cs_log(sender
,"NEWPASS FAIL username %s password to short %s (%d characters)",rup
->username
,cargv
[1],strlen(cargv
[1]));
60 for ( i
= 0; cargv
[1][i
] && i
< PASSLEN
; i
++ ) {
61 if ( cargv
[1][i
] == cargv
[1][i
+1] || cargv
[1][i
] + 1 == cargv
[1][i
+1] || cargv
[1][i
] - 1 == cargv
[1][i
+1] )
63 if(isdigit(cargv
[1][i
]))
65 if(islower(cargv
[1][i
]) || isupper(cargv
[1][i
]))
69 if( cntweak
> 3 || !cntdigits
|| !cntletters
) {
70 chanservstdmessage(sender
, QM_PWTOWEAK
); /* new password is weak */
71 cs_log(sender
,"NEWPASS FAIL username %s password to weak %s",rup
->username
,cargv
[1]);
75 if(!UHasHelperPriv(rup
)) {
77 if(rup
->lockuntil
&& rup
->lockuntil
> t
) {
79 strftime(buf
, 15, "%d/%m/%y %H:%M", gmtime(&(rup
->lockuntil
)));
80 chanservstdmessage(sender
, QM_ACCOUNTLOCKED
, buf
);
83 rup
->lockuntil
=t
+7*24*3600;
87 freesstring(rup
->lastemail
);
91 setpassword(rup
, cargv
[1]);
92 rup
->lastauth
=time(NULL
);
93 chanservstdmessage(sender
, QM_PWCHANGED
);
94 cs_log(sender
,"NEWPASS OK username %s", rup
->username
);
96 #ifdef AUTHGATE_WARNINGS
97 if(UHasHelperPriv(rup
))
98 chanservsendmessage(sender
, "You MUST go to https://auth.quakenet.org and login successfully to update the cache.");
101 csdb_updateuser(rup
);
102 csdb_createmail(rup
, QMAIL_NEWPW
);