Init Git Prod Mars 2026
This commit is contained in:
commit
d81efe93b1
362 files changed
+86627
No files matched your search
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once '../vendor/autoload.php';
|
||||
require_once __DIR__ . '/../public/includes/init_praticien.php';
|
||||
$config = require 'config_google.php';
|
||||
|
||||
$client = new Google_Client();
|
||||
$client->setClientId($config['client_id']);
|
||||
$client->setClientSecret($config['client_secret']);
|
||||
$client->setRedirectUri($config['redirect_uri']);
|
||||
|
||||
if (isset($_GET['code'])) {
|
||||
$client->authenticate($_GET['code']);
|
||||
$token = $client->getAccessToken();
|
||||
|
||||
if (!isset($_SESSION['reference_id']) || $_SESSION['role'] !== 'praticien') {
|
||||
die("Utilisateur non connecté.");
|
||||
}
|
||||
|
||||
$praticien_id = $_SESSION['reference_id'];
|
||||
|
||||
// Vérifier si un token existe déjà
|
||||
$stmt = $pdo->prepare("SELECT id FROM google_tokens WHERE praticien_id = ?");
|
||||
$stmt->execute([$praticien_id]);
|
||||
|
||||
$data = [
|
||||
'access_token' => $token['access_token'],
|
||||
'refresh_token' => $token['refresh_token'] ?? '',
|
||||
'expires_at' => time() + $token['expires_in']
|
||||
];
|
||||
|
||||
if ($stmt->fetch()) {
|
||||
$stmt = $pdo->prepare("UPDATE google_tokens SET access_token = ?, refresh_token = ?, expires_at = ? WHERE praticien_id = ?");
|
||||
} else {
|
||||
$stmt = $pdo->prepare("INSERT INTO google_tokens (access_token, refresh_token, expires_at, praticien_id) VALUES (?, ?, ?, ?)");
|
||||
}
|
||||
|
||||
$stmt->execute([$data['access_token'], $data['refresh_token'], $data['expires_at'], $praticien_id]);
|
||||
|
||||
echo <<<HTML
|
||||
<div class="container">
|
||||
<div class="d-flex justify-content-center align-items-center" style="min-height:48vh;">
|
||||
<div class="card shadow-lg border-0 text-center" style="max-width:720px; width:100%; border-radius:18px;">
|
||||
<div class="card-body p-4">
|
||||
<div class="display-6 mb-2">✅</div>
|
||||
<h2 class="h4 mb-2">Подключение к Google Календарю выполнено успешно</h2>
|
||||
<p class="text-muted mb-4">Вы можете вернуться в календарь или запустить синхронизацию прямо сейчас.</p>
|
||||
<div class="d-flex gap-2 justify-content-center">
|
||||
<a href="/synchroniser_google.php" class="btn btn-primary btn-lg rounded-pill">
|
||||
Синхронизировать календарь
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
HTML;
|
||||
} else {
|
||||
echo <<<HTML
|
||||
<div class="container py-4">
|
||||
<div class="alert alert-danger text-center mx-auto" role="alert" style="max-width:720px;">
|
||||
❌ Не передан код авторизации Google. Попробуйте выполнить вход ещё раз.
|
||||
</div>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
?>
|
||||
|
||||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||
Reference in new issue
Block a user