mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Initial commit
This commit is contained in:
38
includes/login.php
Normal file
38
includes/login.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
require_once 'includes/config.php';
|
||||
require_once 'includes/functions.php';
|
||||
|
||||
/**
|
||||
* Handler for administrative user login
|
||||
*/
|
||||
function DisplayLogin()
|
||||
{
|
||||
// initialize auth object
|
||||
$auth = new \RaspAP\Auth\HTTPAuth;
|
||||
|
||||
// handle page action
|
||||
if (RASPI_AUTH_ENABLED) {
|
||||
if (isset($_POST['login-auth'])) {
|
||||
// authenticate user
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
$redirectUrl = $_POST['redirect-url'];
|
||||
if ($auth->login($username, $password)) {
|
||||
$config = $auth->getAuthConfig();
|
||||
header('Location: ' . $redirectUrl);
|
||||
die();
|
||||
} else {
|
||||
$status = "Login failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo renderTemplate(
|
||||
"login", compact(
|
||||
"status",
|
||||
"redirectUrl"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user