X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/5a7f0cdef67d69cc3569bb93df6f68703ec8065d..1a6051dbe0c8afe3247c45432db941e2f69ab449:/login/index.php diff --git a/login/index.php b/login/index.php index da0ca1e..d2d1700 100644 --- a/login/index.php +++ b/login/index.php @@ -1,9 +1,17 @@ - id) && $user->password_verify($_POST['password'])) + $hash_needs_updating = false; + if (isset($user->id) && $user->password_verify($_POST['password'], $hash_needs_updating)) { + /* SUCCESSFUL LOGIN */ + if ($hash_needs_updating) + { + /* Set password again so it is freshly hashed */ + $hash = PanelUser::password_hash($_POST['password']); + $ar = ["update_pass_conf"=>$hash]; + $user->update_core_info($ar); + unset($ar); + unset($hash); + } + panel_start_session($user); $_SESSION['id'] = $user->id; - header('Location: ' . $redirect); $user->add_meta("last_login", date("Y-m-d H:i:s")); Hook::run(HOOKTYPE_USER_LOGIN, $user); + + /* Middle of install? Override redirect: */ + if (!isset($config['unrealircd'])) + $redirect = get_config("base_url")."settings/rpc-servers.php"; + header('Location: ' . $redirect); die(); } else { + /* LOGIN FAILED */ $fail = [ "login" => htmlspecialchars($_POST['username']), "IP" => $_SERVER['REMOTE_ADDR'] @@ -48,8 +76,8 @@ if (!empty($_POST)) ?> - - +css/unrealircd-admin.css" rel="stylesheet"> + @@ -65,7 +93,7 @@ if (!empty($_POST)) - +img/favicon.ico"> UnrealIRCd Panel
@@ -74,8 +102,8 @@ if (!empty($_POST))
-
-

Log in to use Admin Panel

+ +

img/favicon.ico"> Log in to use Admin Panel

-
+
-
+
+
+ Username cannot be empty. +
+
-
+
-
+
+
+ Password cannot be empty. +
+
@@ -102,4 +138,31 @@ if (!empty($_POST))
- + var form = document.getElementById('login'); + var pinp = document.getElementById('passinp'); + var uinp = document.getElementById('userinp'); + + form.addEventListener('submit', (event) => + { + event.preventDefault(); + var err = 0; + if (uinp.value.length == 0) + { + $('#user_inv').show(); + err++; + } + if (pinp.value.length == 0) + { + $('#pass_inv').show(); + err++; + } + if (err) + return; + else + form.submit(); + }); + + +