-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace requestpassword with lostpassword #8
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* CMDNAME: lostpassword | ||
* CMDALIASES: lostpass | ||
* CMDLEVEL: QCMD_NOTAUTHED | ||
* CMDARGS: 2 | ||
* CMDDESC: Sends a code to reset the password with. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sends instructions for resetting your account to your registered email address. |
||
* CMDFUNC: csa_dolostpw | ||
* CMDPROTO: int csa_dolostpw(void *source, int cargc, char **cargv); | ||
* CMDHELP: Usage: @UCOMMAND@ <email> | ||
* CMDHELP: Sends instructions for resetting your account to your registered email address, where: | ||
* CMDHELP: email - your email address | ||
*/ | ||
|
||
#include "../chanserv.h" | ||
#include "../authlib.h" | ||
#include "../../lib/irc_string.h" | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int csa_dolostpw(void *source, int cargc, char **cargv) { | ||
reguser *rup; | ||
nick *sender=source; | ||
time_t t; | ||
int i, matched = 0; | ||
|
||
if (cargc<1) { | ||
chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "lostpassword"); | ||
return CMD_ERROR; | ||
} | ||
|
||
t=time(NULL); | ||
|
||
for (i=0;i<REGUSERHASHSIZE;i++) { | ||
for (rup=regusernicktable[i];rup;rup=rup->nextbyname) { | ||
if(!rup->email || strcasecmp(cargv[0],rup->email->content)) | ||
continue; | ||
|
||
if(UHasStaffPriv(rup)) { | ||
cs_log(sender,"LOSTPASSWORD FAIL privileged email %s",cargv[0]); | ||
continue; | ||
} | ||
|
||
matched = 1; | ||
|
||
if(rup->lockuntil && rup->lockuntil > t) { | ||
chanservstdmessage(sender, QM_ACCOUNTLOCKED, rup->lockuntil); | ||
continue; | ||
} | ||
|
||
if(csa_checkthrottled(sender, rup, "LOSTPASSWORD")) | ||
continue; | ||
|
||
rup->lockuntil=t; | ||
rup->lastemailchange=t; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does lastemailchange change? |
||
csdb_updateuser(rup); | ||
|
||
if(rup->lastauth) { | ||
csdb_createmail(rup, QMAIL_LOSTPW); | ||
} else { | ||
csdb_createmail(rup, QMAIL_NEWACCOUNT); /* user hasn't authed yet and needs to do the captcha */ | ||
} | ||
|
||
cs_log(sender,"LOSTPASSWORD OK username %s email %s", rup->username, rup->email->content); | ||
chanservstdmessage(sender, QM_MAILQUEUED); | ||
} | ||
} | ||
|
||
if(!matched) { | ||
cs_log(sender,"LOSTPASSWORD FAIL email %s",cargv[0]); | ||
chanservstdmessage(sender, QM_BADEMAIL); | ||
return CMD_ERROR; | ||
} else { | ||
chanservstdmessage(sender, QM_DONE); | ||
} | ||
|
||
return CMD_OK; | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* CMDNAME: resetpassword | ||
* CMDALIASES: resetpass | ||
* CMDLEVEL: QCMD_SECURE | QCMD_NOTAUTHED | ||
* CMDARGS: 4 | ||
* CMDDESC: Resets the password. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replace with:
|
||
* CMDFUNC: csa_dorespw | ||
* CMDPROTO: int csa_dorespw(void *source, int cargc, char **cargv); | ||
* CMDHELP: Usage: @UCOMMAND@ <account> <newpass> <newpass> <code> | ||
* CMDHELP: Resets your password using the code received on your registered email address, where: | ||
* CMDHELP: username - your username | ||
* CMDHELP: newpass - your desired new password. Must be entered the same both times. | ||
* CMDHELP: code - the code received in the RESET email. | ||
*/ | ||
|
||
#include "../chanserv.h" | ||
#include "../authlib.h" | ||
#include "../../lib/irc_string.h" | ||
#include "../../lib/hmac.h" | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int csa_dorespw(void *source, int cargc, char **cargv) { | ||
reguser *rup; | ||
nick *sender=source; | ||
unsigned int same=0; | ||
int pq; | ||
time_t t; | ||
|
||
if (cargc<4) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. plaese swap the code so it is before the "newpass" -- the user will probably have to change their pass a few times so putting the code first makes it easier |
||
chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "resetpassword"); | ||
return CMD_ERROR; | ||
} | ||
|
||
if (!(rup=findreguser(sender, cargv[0]))) | ||
return CMD_ERROR; | ||
|
||
if (strcmp(cargv[1],cargv[2])) { | ||
chanservstdmessage(sender, QM_PWDONTMATCH); /* Sorry, passwords do not match */ | ||
cs_log(sender,"RESETPASS FAIL username %s new passwords don't match (%s vs %s)",rup->username,cargv[1],cargv[2]); | ||
return CMD_ERROR; | ||
} | ||
|
||
if (!hmac_strcmp(rup->password,cargv[1])) { | ||
/* If they are the same then continue anyway but don't send the hook later. */ | ||
same=1; | ||
} | ||
|
||
pq = csa_checkpasswordquality(cargv[1]); | ||
if(pq == QM_PWTOSHORT) { | ||
chanservstdmessage(sender, QM_PWTOSHORT); /* new password too short */ | ||
cs_log(sender,"RESETPASS FAIL username %s password too short %s (%zu characters)",rup->username,cargv[1],strlen(cargv[1])); | ||
return CMD_ERROR; | ||
} else if(pq == QM_PWTOWEAK) { | ||
chanservstdmessage(sender, QM_PWTOWEAK); /* new password is weak */ | ||
cs_log(sender,"RESETPASS FAIL username %s password too weak %s",rup->username,cargv[1]); | ||
return CMD_ERROR; | ||
} else if(pq == QM_PWTOLONG) { | ||
chanservstdmessage(sender, QM_PWTOLONG); /* new password too long */ | ||
cs_log(sender,"RESETPASS FAIL username %s password too long %s",rup->username,cargv[1]); | ||
return CMD_ERROR; | ||
} else if(pq == -1) { | ||
/* all good */ | ||
} else { | ||
chanservsendmessage(sender, "unknown error in resetpass.c... contact #help"); | ||
return CMD_ERROR; | ||
} | ||
|
||
if(UHasStaffPriv(rup) || !rup->lockuntil || hmac_strcmp(cargv[3], csc_generateresetcode(rup->lockuntil, rup->username))) { | ||
chanservstdmessage(sender, QM_BADRESETCODE); | ||
return CMD_ERROR; | ||
} | ||
|
||
t=time(NULL); | ||
|
||
if(rup->lockuntil > t) { | ||
chanservstdmessage(sender, QM_ACCOUNTLOCKED, rup->lockuntil); | ||
return CMD_ERROR; | ||
} | ||
|
||
rup->lockuntil=t+7*24*3600; | ||
|
||
if(rup->lastemail) { | ||
freesstring(rup->lastemail); | ||
rup->lastemail=NULL; | ||
} | ||
|
||
rup->lastpasschange=t; | ||
csdb_accounthistory_insert(sender, rup->password, cargv[1], NULL, NULL); | ||
setpassword(rup, cargv[1]); | ||
|
||
rup->lastauth=t; | ||
chanservstdmessage(sender, QM_PWCHANGED); | ||
cs_log(sender,"RESETPASS OK username %s", rup->username); | ||
|
||
#ifdef AUTHGATE_WARNINGS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. priv users can't do this at all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same usage as in newpass: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. newpass can be used by priv accounts, this command can't be |
||
if(UHasOperPriv(rup)) | ||
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."); | ||
#endif | ||
|
||
csdb_updateuser(rup); | ||
csdb_createmail(rup, QMAIL_NEWPW); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this send out a reset code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, i looked at it - reset codes aren't sent for staffers, and also getting blocked on an "if (UHasStaffPriv(..." before (line 68). |
||
|
||
if (!same) | ||
triggerhook(HOOK_CHANSERV_PWCHANGE, sender); | ||
|
||
return CMD_OK; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
/* Automatically generated by refactor.pl. | ||
* | ||
* | ||
* CMDNAME: sendpassword | ||
/* CMDNAME: sendpassword | ||
* CMDALIASES: sendpass | ||
* CMDLEVEL: QCMD_HELPER | ||
* CMDARGS: 1 | ||
* CMDDESC: Sends the users current password by email. | ||
* CMDDESC: Sends the user a reset code to the email. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "to their email address" |
||
* CMDFUNC: csa_dosendpw | ||
* CMDPROTO: int csa_dosendpw(void *source, int cargc, char **cargv); | ||
* CMDHELP: Usage: @UCOMMAND@ <username> | ||
* CMDHELP: Sends the password for the specified account to the specified users email address. | ||
* CMDHELP: Sends the password for the specified account to the user's email address. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keep this as it was |
||
*/ | ||
|
||
#include "../chanserv.h" | ||
|
@@ -21,6 +18,7 @@ | |
int csa_dosendpw(void *source, int cargc, char **cargv) { | ||
reguser *rup; | ||
nick *sender=source; | ||
time_t t; | ||
|
||
if (cargc<1) { | ||
chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "sendpassword"); | ||
|
@@ -36,16 +34,23 @@ int csa_dosendpw(void *source, int cargc, char **cargv) { | |
return CMD_ERROR; | ||
} | ||
|
||
/* we don't reset the throttling timer | ||
rup->lastemailchange=time(NULL); | ||
csdb_updateuser(rup); | ||
*/ | ||
t = time(NULL); | ||
|
||
if(rup->lastauth) { | ||
csdb_createmail(rup, QMAIL_REQPW); | ||
if(rup->lockuntil && rup->lockuntil > t) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so if they have 1 second to go you'll send the same code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reset codes work pretty much the same on other commands like RESET, but sure we can change that to.. like, 5 minutes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's not what I'm saying if the user has 1 second to go you'll send them a useless code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so what should i do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a), but I'd make it 30 minutes |
||
// Send same reset code. | ||
csdb_createmail(rup, QMAIL_NEWPW); | ||
} else { | ||
csdb_createmail(rup, QMAIL_NEWACCOUNT); /* user hasn't authed yet and needs to do the captcha */ | ||
rup->lockuntil=t; | ||
rup->lastemailchange=t; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why change lastemailchange ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just replicating what requestpassword did: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is it there though? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
csdb_updateuser(rup); | ||
|
||
if(rup->lastauth) { | ||
csdb_createmail(rup, QMAIL_LOSTPW); | ||
} else { | ||
csdb_createmail(rup, QMAIL_NEWACCOUNT); /* user hasn't authed yet and needs to do the captcha */ | ||
} | ||
} | ||
|
||
chanservstdmessage(sender, QM_MAILQUEUED); | ||
cs_log(sender,"SENDPASSWORD username %s", rup->username); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ CONFIG = { | |
"smtpauth": None, | ||
"templateoptions": { | ||
"bot": "Q9", | ||
"botsecure": "Q9@CServe.test.quakenet.org", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can make this out of "bot" and "server" |
||
"cleanup": 80, | ||
"securityurl": "http://www.quakenet.org/faq/faq.php?c=160", | ||
"siteurl": "http://www.quakenet.org/", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,14 @@ def generate_resetcode(config, obj): | |
obj["lockuntil"] = time.ctime(obj["user.lockuntil"]) | ||
obj["resetline"] = "/MSG %(config.bot)s RESET #%(user.username)s %(resetcode)s" % obj | ||
|
||
def generate_resetpassword(config, obj): | ||
generate_resetcode(config, obj) | ||
obj["resetline"] = "/MSG %(config.botsecure)s RESETPASSWORD #%(user.username)s <newpass> <newpass> %(resetcode)s" %obj | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. newpassword newpassword (+ put code at beginning) |
||
|
||
MAILTEMPLATES = { | ||
"mutators": { | ||
1: generate_url, | ||
2: generate_resetpassword, | ||
3: generate_resetcode, | ||
5: generate_resetcode, | ||
6: generate_activation_url, | ||
|
@@ -85,15 +90,15 @@ def generate_resetcode(config, obj): | |
NB: Save this email for future reference. | ||
""", | ||
}, | ||
2: { "subject": "%(config.bot)s password request", "body": """ | ||
Your username/password is: | ||
2: { "subject": "%(config.bot)s reset password", "body": """ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "password reset request" instead of "reset password" |
||
A password reset was requested for your account, to reset your password please use: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was -> has been |
||
%(resetline)s | ||
|
||
Username: %(user.username)s | ||
Password: %(user.password)s | ||
Where <newpass> should be replaced with your desired password. | ||
|
||
To auth yourself to %(config.bot)s, type the following command | ||
For more information please visit the resetpassword help link at http://www.quakenet.org/help/q-commands/resetpassword | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. newpass -> newpassword "For more information please visit: https://www.quakenet.org/help/q-commands/resetpassword" also URL needs to exist |
||
|
||
/MSG %(config.bot)s@%(config.server)s AUTH %(user.username)s %(user.password)s | ||
If it was not you who issued this command, please disregard this mail. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "If you did not issue this command, you can ignore this email and no changes will made to your account." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ack, "will made" should be "will be made" |
||
""", }, | ||
3: { "subject": "%(config.bot)s password change", "body": """ | ||
Your password has recently changed. If this was not requested by you, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1