More detailed login logging

This commit is contained in:
Shish 2019-04-26 10:13:31 +01:00
parent 52dfa12df7
commit 80c84f3248
2 changed files with 8 additions and 2 deletions

View File

@ -105,11 +105,19 @@ class User {
$user = User::by_name($name);
if($user) {
if($user->passhash == md5(strtolower($name) . $pass)) {
log_info("core-user", "Migrating from md5 to bcrypt for ".html_escape($name));
$user->set_password($pass);
}
if(password_verify($pass, $user->passhash)) {
log_info("core-user", "Logged in as ".html_escape($name)." ({$user->class->name})");
return $user;
}
else {
log_warning("core-user", "Failed to log in as ".html_escape($name)." (Invalid password)");
}
}
else {
log_warning("core-user", "Failed to log in as ".html_escape($name)." (Invalid username)");
}
return null;
}

View File

@ -346,7 +346,6 @@ class UserPage extends Extension {
if(!is_null($duser)) {
$user = $duser;
$this->set_login_cookie($duser->name, $pass);
log_info("user", "{$user->class->name} logged in");
$page->set_mode("redirect");
// Try returning to previous page
@ -360,7 +359,6 @@ class UserPage extends Extension {
}
}
else {
log_warning("user", "Failed to log in as ".html_escape($name));
$this->theme->display_error(401, "Error", "No user with those details was found");
}
}