| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | require __DIR__ . '/lib/bootstrap.php'; |
| 4 | |
| 5 | try { |
| 6 | if (localDev() && isset($_GET['test'])) { |
| 7 | $who = $_GET['test'] === '2' ? 'test_user_2' : 'test_user_1'; |
| 8 | loginUser('local:' . $who, $who); |
| 9 | $next = isset($_GET['next']) && is_string($_GET['next']) ? $_GET['next'] : 'index.html'; |
| 10 | header('Location: ' . $next); |
| 11 | exit; |
| 12 | } |
| 13 | if (!authConfigured()) { |
| 14 | header('Location: index.html?auth=unconfigured'); |
| 15 | exit; |
| 16 | } |
| 17 | $cfg = config(); |
| 18 | $_SESSION['oauth_state'] = bin2hex(random_bytes(32)); |
| 19 | $_SESSION['oauth_started'] = time(); |
| 20 | header('Location: ' . authUrl() . '/oauth/authorize?' . http_build_query([ |
| 21 | 'client_id' => $cfg['client_id'], |
| 22 | 'redirect_uri' => baseUrl() . '/callback.php', |
| 23 | 'response_type' => 'code', |
| 24 | 'state' => $_SESSION['oauth_state'], |
| 25 | ])); |
| 26 | } catch (Throwable $e) { |
| 27 | http_response_code(503); |
| 28 | header('Content-Type: text/html; charset=utf-8'); |
| 29 | echo '<!DOCTYPE html><meta charset="utf-8"><title>Meteors</title>'; |
| 30 | echo '<p>Inloggen is nu niet mogelijk. ' . htmlspecialchars($e->getMessage()) . '</p>'; |
| 31 | echo '<p><a href="index.html">Terug naar het spel</a></p>'; |
| 32 | } |
projects-timfalken-com meteors