Update: 2026-06-11 18:22:57
This commit is contained in:
48
walletintaleq.intaleq.xyz/v2/main/jwtconnect.php
Executable file
48
walletintaleq.intaleq.xyz/v2/main/jwtconnect.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// Load environment variables from .env file
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
require_once 'load_env.php';
|
||||
$env_file = '/home/intaleq-wallet/env/.env';
|
||||
loadEnvironment($env_file);
|
||||
|
||||
// Get environment variables (You don't need user/pass for JWT auth itself)
|
||||
$secretKey = getenv('SECRET_KEY'); // Only need the secret key now
|
||||
|
||||
// --- CORS Headers ---
|
||||
header("Access-Control-Allow-Origin: *"); // Replace * with your Flutter app's origin!
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); // Adjust as needed
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization");
|
||||
header('Content-Type: application/json'); // Set content type to JSON
|
||||
|
||||
// Handle preflight requests (OPTIONS)
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
$dbname = getenv('dbname');
|
||||
// --- Database Connection (Still needed for your application logic) ---
|
||||
try {
|
||||
$dsn = "mysql:host=localhost;dbname=$dbname;charset=utf8mb4";
|
||||
$options = [
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF8"
|
||||
];
|
||||
$user = getenv('USER'); // Still used for DB connection
|
||||
$pass = getenv('PASS'); // Still used for DB connection
|
||||
$con = new PDO($dsn, $user, $pass, $options);
|
||||
|
||||
// --- JWT Authentication ---
|
||||
include "functions.php"; // Include the functions file
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (PDOException $e) {
|
||||
error_log($e->getMessage());
|
||||
http_response_code(500); // Internal Server Error
|
||||
echo json_encode(['error' => 'A database error occurred.']);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user