feat(integrations): add role-based security and 1-click Outlook connect for colleagues
This commit is contained in:
@@ -9,22 +9,17 @@ 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) ?: [];
|
||||
// Haal centrale Microsoft app configuratie op (env of admin instellingen)
|
||||
$appConfig = microsoft_get_app_config();
|
||||
|
||||
$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'));
|
||||
$clientId = !empty($_GET['client_id']) ? trim($_GET['client_id']) : $appConfig['client_id'];
|
||||
$tenantId = !empty($_GET['tenant_id']) ? trim($_GET['tenant_id']) : $appConfig['tenant_id'];
|
||||
|
||||
if (empty($clientId)) {
|
||||
header('Location: /integrations.php?error=' . urlencode('Vul eerst de Application (Client) ID en het Client Secret in bij de Outlook instellingen om te koppelen met Microsoft 365.'));
|
||||
$err = ($user['role'] === 'ADMIN')
|
||||
? 'Vul eerst de Application (Client) ID en het Client Secret in bij de Outlook instellingen om te koppelen met Microsoft 365.'
|
||||
: 'Microsoft 365 is nog niet geconfigureerd door de beheerder van uw organisatie. Vraag uw beheerder om de koppeling in te stellen.';
|
||||
header('Location: /integrations.php?error=' . urlencode($err));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user