]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - login/index.php
The config file now contains 'secrets' with 'pepper' that is used for
[irc/unrealircd/unrealircd-webpanel.git] / login / index.php
index 97cc98ad5f271e51096c3663fd95a68d0da68f14..bea6f0ae9e491f48779080bec745872fd531fe72 100644 (file)
@@ -1,4 +1,3 @@
-
 <?php
 require_once "../common.php";
 
@@ -35,12 +34,24 @@ if (!empty($_POST))
        {
                $user = new PanelUser($_POST['username']);
                /* not being too informative with the login error in case of attackers */
-               if (isset($user->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;
                        $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']) || empty($config['unrealircd']['host']))
                                $redirect = get_config("base_url")."settings/install2.php";
@@ -49,6 +60,7 @@ if (!empty($_POST))
                }
                else
                {
+                       /* LOGIN FAILED */
                        $fail = [
                                "login" => htmlspecialchars($_POST['username']),
                                "IP" => $_SERVER['REMOTE_ADDR']