Fixed broken password recovery

SVN revision: 2372
This commit is contained in:
Stefan Ritt 2011-01-20 15:25:15 +00:00
parent 8098de8384
commit aaf2975f20

View File

@ -12649,7 +12649,7 @@ int save_user_config(LOGBOOK * lbs, char *user, BOOL new_user)
{ {
char file_name[256], str[256], *pl, user_enc[256], new_pwd[80], new_pwd2[80], smtp_host[256], char file_name[256], str[256], *pl, user_enc[256], new_pwd[80], new_pwd2[80], smtp_host[256],
email_addr[256], mail_from[256], mail_from_name[256], subject[256], mail_text[2000], str2[256], email_addr[256], mail_from[256], mail_from_name[256], subject[256], mail_text[2000], str2[256],
admin_user[80], url[256], error[2000], auth[32]; admin_user[80], url[256], error[2000];
int i, self_register, code, first_user; int i, self_register, code, first_user;
PMXML_NODE node, subnode, npwd; PMXML_NODE node, subnode, npwd;
@ -12689,18 +12689,15 @@ int save_user_config(LOGBOOK * lbs, char *user, BOOL new_user)
} }
/* check for blank password if not external authentication*/ /* check for blank password if not external authentication*/
getcfg(lbs->name, "Authentication", auth, sizeof(auth)); if (isparam("newpwd")) {
if (stristr(auth, "Kerberos") == NULL) { strlcpy(str, getparam("newpwd"), sizeof(str));
if (isparam("newpwd")) { if (str[0] == 0) {
strlcpy(str, getparam("newpwd"), sizeof(str)); show_error(loc("Empty password not allowed"));
if (str[0] == 0) { return 0;
show_error(loc("Empty password not allowed")); }
return 0; if (strchr(str, ' ')) {
} show_error(loc("Password may not contain blanks"));
if (strchr(str, ' ')) { return 0;
show_error(loc("Password may not contain blanks"));
return 0;
}
} }
} }
@ -12709,17 +12706,15 @@ int save_user_config(LOGBOOK * lbs, char *user, BOOL new_user)
if (getcfg(lbs->name, "Self register", str, sizeof(str))) if (getcfg(lbs->name, "Self register", str, sizeof(str)))
self_register = atoi(str); self_register = atoi(str);
/* check if passwords match */
new_pwd[0] = 0; new_pwd[0] = 0;
if (stristr(auth, "Kerberos") == NULL) { if (isparam("newpwd") && isparam("newpwd2")) {
/* check if passwords match */ strlcpy(new_pwd, getparam("newpwd"), sizeof(new_pwd));
if (isparam("newpwd") && isparam("newpwd2")) { strlcpy(new_pwd2, getparam("newpwd2"), sizeof(new_pwd2));
do_crypt(getparam("newpwd"), new_pwd, sizeof(new_pwd));
do_crypt(getparam("newpwd2"), new_pwd2, sizeof(new_pwd2));
if (strcmp(new_pwd, new_pwd2) != 0) { if (strcmp(new_pwd, new_pwd2) != 0) {
show_error(loc("New passwords do not match, please retype")); show_error(loc("New passwords do not match, please retype"));
return 0; return 0;
}
} }
} }
@ -12767,7 +12762,8 @@ int save_user_config(LOGBOOK * lbs, char *user, BOOL new_user)
strencode2(str, getparam("new_user_name"), sizeof(str)); strencode2(str, getparam("new_user_name"), sizeof(str));
mxml_add_node(node, "name", str); mxml_add_node(node, "name", str);
} }
npwd = mxml_add_node(node, "password", new_pwd); do_crypt(new_pwd, str, sizeof(str));
npwd = mxml_add_node(node, "password", str);
if (npwd) if (npwd)
mxml_add_attribute(npwd, "encoding", "SHA256"); mxml_add_attribute(npwd, "encoding", "SHA256");
@ -13572,8 +13568,6 @@ void show_forgot_pwd_page(LOGBOOK * lbs)
void show_new_user_page(LOGBOOK * lbs, char *user) void show_new_user_page(LOGBOOK * lbs, char *user)
{ {
char auth[32];
/*---- header ----*/ /*---- header ----*/
show_html_header(lbs, TRUE, loc("ELOG new user"), TRUE, FALSE, NULL, FALSE); show_html_header(lbs, TRUE, loc("ELOG new user"), TRUE, FALSE, NULL, FALSE);
@ -13610,15 +13604,11 @@ void show_new_user_page(LOGBOOK * lbs, char *user)
rsprintf("<tr><td nowrap>Email:</td>\n"); rsprintf("<tr><td nowrap>Email:</td>\n");
rsprintf("<td colspan=2><input type=text size=40 name=new_user_email></tr>\n"); rsprintf("<td colspan=2><input type=text size=40 name=new_user_email></tr>\n");
/* don't need a password for extenral authentication */ rsprintf("<tr><td nowrap>%s:</td>\n", loc("Password"));
getcfg(lbs->name, "Authentication", auth, sizeof(auth)); rsprintf("<td colspan=2><input type=password size=40 name=newpwd>\n");
if (stristr(auth, "Kerberos") == NULL) {
rsprintf("<tr><td nowrap>%s:</td>\n", loc("Password"));
rsprintf("<td colspan=2><input type=password size=40 name=newpwd>\n");
rsprintf("<tr><td nowrap>%s:</td>\n", loc("Retype password")); rsprintf("<tr><td nowrap>%s:</td>\n", loc("Retype password"));
rsprintf("<td colspan=2><input type=password size=40 name=newpwd2>\n"); rsprintf("<td colspan=2><input type=password size=40 name=newpwd2>\n");
}
rsprintf("</td></tr></table>\n"); rsprintf("</td></tr></table>\n");