Files
transfer.tapee.ac.th/login-google.php
T
pongpon pitisuk 72701ad58c Initial import
2026-06-25 16:49:13 +07:00

23 lines
576 B
PHP

<?php
require_once __DIR__ . '/config.php';
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true) {
header('Location: ' . BASE_URL . '/index.php');
exit;
}
$state = bin2hex(random_bytes(16));
$_SESSION['google_state'] = $state;
$params = [
'client_id' => GOOGLE_CLIENT_ID,
'redirect_uri' => GOOGLE_REDIRECT_URI,
'response_type' => 'code',
'scope' => 'openid email profile',
'access_type' => 'online',
'state' => $state,
];
header('Location: https://accounts.google.com/o/oauth2/v2/auth?' . http_build_query($params));
exit;