]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - login/index.php
Fix "last login" meta and display on PanelUsers page
[irc/unrealircd/unrealircd-webpanel.git] / login / index.php
index d7a1781b5fbfcb9cba9eecc727c2134272bf7e69..4c625e2e4072976b145e461a4d342288ef409993 100644 (file)
@@ -24,18 +24,21 @@ if (!empty($_POST))
                $user = new PanelUser($_POST['username']);
                
                /* not being too informative with the login error in case of attackers */
-               if (!$user->id)
-               {
-                       $failmsg = "Incorrect login";
-               }
-               else if ($user->password_verify($_POST['password']))
+               if (isset($user->id) && $user->password_verify($_POST['password']))
                {
                        $_SESSION['id'] = $user->id;
                        header('Location: ' . $redirect);
-                       $user->add_meta("last_login", date("Y-m-d m:i:s"));
+                       $user->add_meta("last_login", date("Y-m-d H:i:s"));
+                       Hook::run(HOOKTYPE_USER_LOGIN, $user);
+                       die();
                }
                else
                {
+                       $fail = [
+                               "login" => htmlspecialchars($_POST['username']),
+                               "IP" => $_SERVER['REMOTE_ADDR']
+                       ];
+                       Hook::run(HOOKTYPE_USER_LOGIN_FAIL, $fail);
                        $failmsg = "Incorrect login";
                }
 
@@ -65,20 +68,17 @@ if (!empty($_POST))
 <title>UnrealIRCd Panel</title>
 <link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>img/favicon.ico">
 <link href="<?php echo BASE_URL; ?>css/unrealircd-admin.css" rel="stylesheet">
-</head><div class="text-center">
-<a href="<?php echo BASE_URL; ?>login"><button type="button" style="margin:0; top:50%; position: absolute;" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#loginModaltitle">
-       Login to continue
-</button></a>
-</div>
+</head>
 <script>
        $(document).ready(function(){
-               $("#loginModal").modal('show');
+               $("#loginModal").modal({backdrop: 'static', keyboard: false}, 'show');
        });
+
 </script>
 <body role="document">
 <div class="container-fluid">
 <form method="post" action="index.php?redirect=<?php echo $redirect; ?>">
-       <div class="modal" id="loginModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="loginModal" aria-hidden="true">
+       <div class="modal" id="loginModal" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="loginModal" aria-hidden="false"></a>
        <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                <div class="modal-header" style="margin: 0 auto;">