diff --git a/routes/calendar.routes.js b/routes/calendar.routes.js index 516c13a..4b3183c 100644 --- a/routes/calendar.routes.js +++ b/routes/calendar.routes.js @@ -33,14 +33,19 @@ async function getAuthType() { async function getOAuth2Client(customRedirectUri = null) { const clientId = await getOne("SELECT value FROM settings WHERE key = 'google_client_id'"); const clientSecret = await getOne("SELECT value FROM settings WHERE key = 'google_client_secret'"); + const appUrl = await getOne("SELECT value FROM settings WHERE key = 'app_url'"); if (!clientId || !clientId.value || !clientSecret || !clientSecret.value) { throw new Error('Client ID et Client Secret non configurés'); } - // Utiliser l'URI personnalisée si fournie, sinon utiliser l'URL de production + // Utiliser l'URI personnalisée si fournie, sinon utiliser l'URL du site configurée const redirectUri = customRedirectUri || - 'https://note.ffnancy.fr/api/calendar/oauth-callback'; + (appUrl?.value ? `${appUrl.value}/api/calendar/oauth-callback` : null); + + if (!redirectUri) { + throw new Error('URL du site non configurée. Veuillez configurer l\'URL dans les paramètres.'); + } return new google.auth.OAuth2( clientId.value, diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index 272061e..4963e83 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -98,7 +98,6 @@ const Index = () => { const [chatLoading, setChatLoading] = useState(false); const [selectedModel, setSelectedModel] = useState(""); const [defaultModel, setDefaultModel] = useState(""); - const [modelSearchQuery, setModelSearchQuery] = useState(""); // Debounce timer for auto-save const saveTimerRef = useRef(null); @@ -1711,182 +1710,63 @@ const Index = () => { - Configuration Google Calendar + Configuration Google Calendar OAuth 2.0 - {/* Choix du type d'authentification */}
- - -

- OAuth 2.0 : Pour accéder au calendrier personnel avec autorisation de l'utilisateur.
- Service Account : Pour accéder à des calendriers partagés sans interaction utilisateur.
- API externe : Utilisez votre propre API backend pour gérer la connexion à Google Calendar. + + setSettings({ ...settings, app_url: e.target.value })} + /> +

+ URL de votre site (utilisée pour les redirections OAuth)

- {/* Configuration OAuth2 */} - {(!settings.google_auth_type || settings.google_auth_type === 'oauth2') && ( - <> -
- - setSettings({ ...settings, google_client_id: e.target.value })} - /> -
+
+ + setSettings({ ...settings, google_client_id: e.target.value })} + /> +
-
- - setSettings({ ...settings, google_client_secret: e.target.value })} - /> -

- Créez un projet OAuth 2.0 sur{' '} - - Google Cloud Console - - {' '}et activez l'API Google Calendar. -

-
-

- ⚠️ IMPORTANT : URI de redirection autorisée -

-

- Ajoutez cette URL exacte dans la console Google Cloud (OAuth 2.0 Client IDs → URIs de redirection autorisées) : -

- - {window.location.origin}/api/calendar/oauth-callback - -

- 💡 Si vous utilisez un domaine différent, créez un fichier .env avec APP_URL=https://votre-domaine.com -

-
-
- - )} - - {/* Configuration Service Account */} - {settings.google_auth_type === 'service_account' && ( - <> -
- -