mirror of
https://github.com/myronblair/tomsjavajive
synced 2026-06-30 17:50:32 -05:00
31 lines
827 B
PHP
31 lines
827 B
PHP
<?php
|
|
/**
|
|
* Redirect to Google OAuth — admin login entry point
|
|
*/
|
|
require_once __DIR__ . '/../../../includes/auth.php';
|
|
|
|
if (AdminAuth::isLoggedIn()) {
|
|
header('Location: /admin/');
|
|
exit;
|
|
}
|
|
|
|
if (!defined('GOOGLE_CLIENT_ID') || !GOOGLE_CLIENT_ID) {
|
|
die('Google OAuth is not configured. Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET in config.');
|
|
}
|
|
|
|
$state = bin2hex(random_bytes(16));
|
|
$_SESSION['google_oauth_state'] = $state;
|
|
|
|
$params = http_build_query([
|
|
'client_id' => GOOGLE_CLIENT_ID,
|
|
'redirect_uri' => GOOGLE_REDIRECT_URI,
|
|
'response_type' => 'code',
|
|
'scope' => 'openid email profile',
|
|
'state' => $state,
|
|
'access_type' => 'online',
|
|
'prompt' => 'select_account',
|
|
]);
|
|
|
|
header('Location: https://accounts.google.com/o/oauth2/v2/auth?' . $params);
|
|
exit;
|