Implementeer live Microsoft 365 Outlook en Atlassian Jira integraties met agendasync en taakimport
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Startpunt voor Microsoft 365 OAuth 2.0 Flow
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../includes/auth.php';
|
||||
require_once __DIR__ . '/../includes/integrations/microsoft.php';
|
||||
|
||||
$user = require_auth();
|
||||
$db = get_db_connection();
|
||||
|
||||
// Haal eventueel opgeslagen client_id en tenant_id op uit database
|
||||
$stmt = $db->prepare("SELECT settings FROM integrations WHERE user_id = ? AND provider = 'OUTLOOK'");
|
||||
$stmt->execute([$user['id']]);
|
||||
$row = $stmt->fetch();
|
||||
$savedSettings = json_decode($row['settings'] ?? '{}', true) ?: [];
|
||||
|
||||
$clientId = !empty($_GET['client_id'])
|
||||
? trim($_GET['client_id'])
|
||||
: (!empty($savedSettings['client_id']) ? $savedSettings['client_id'] : fociz_env('MICROSOFT_CLIENT_ID', ''));
|
||||
|
||||
$tenantId = !empty($_GET['tenant_id'])
|
||||
? trim($_GET['tenant_id'])
|
||||
: (!empty($savedSettings['tenant_id']) ? $savedSettings['tenant_id'] : fociz_env('MICROSOFT_TENANT_ID', 'common'));
|
||||
|
||||
if (empty($clientId)) {
|
||||
header('Location: /integrations.php?error=missing_ms_client_id');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Bepaal de dynamische of geconfigureerde redirect URI
|
||||
$redirectUri = rtrim(APP_URL, '/') . '/auth/callback_microsoft.php';
|
||||
|
||||
// Genereer unieke CSRF state
|
||||
$state = bin2hex(random_bytes(16));
|
||||
$_SESSION['ms_oauth_state'] = $state;
|
||||
$_SESSION['ms_oauth_user_id'] = $user['id'];
|
||||
|
||||
// Stuur gebruiker door naar Microsoft login
|
||||
$authUrl = microsoft_get_auth_url($clientId, $redirectUri, $tenantId, $state);
|
||||
header("Location: {$authUrl}");
|
||||
exit;
|
||||
Reference in New Issue
Block a user