mirror of
https://github.com/myronblair/tomsjavajive
synced 2026-07-28 09:12:36 -05:00
Add Google OAuth admin login; fix header comment; both auth methods active
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?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;
|
||||
Reference in New Issue
Block a user