aaaaa1 / auth.php
Funybubble's picture
Upload 30 files
c7257f7 verified
raw
history blame contribute delete
828 Bytes
<?php
require_once 'config.php';
// Handle admin login
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$data = json_decode(file_get_contents("php://input"));
// Validate admin credentials
if($data->username === 'admin' && $data->password === 'admin123') {
$token = array(
"iss" => "cebelarstvo_cigoj",
"iat" => time(),
"exp" => time() + (60 * 60),
"data" => array(
"username" => "admin",
"role" => "admin"
)
);
$jwt = \Firebase\JWT\JWT::encode($token, JWT_SECRET, 'HS256');
echo json_encode(array("success" => true, "token" => $jwt));
} else {
http_response_code(401);
echo json_encode(array("success" => false, "message" => "Invalid credentials"));
}
}
?>