From 3e71dbe3a35b1b5f600dc9518c487a1e55e23087 Mon Sep 17 00:00:00 2001 From: Sylvain Bettinelli Date: Tue, 5 May 2026 19:15:59 +0000 Subject: [PATCH] Auto-login via token coach_web_token au lancement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - capacitor.config.ts charge coachWebToken depuis coach-ios.local.json (gitignored) - server.url devient https://coach.hypnotruck.ch/login?token=... → backend pose le cookie 1 an, redirige vers / - Au prochain lancement, le cookie tient → /login?token redirige direct vers / - coach-ios.local.json.example fourni pour setup Mac mini --- .gitignore | 1 + README.md | 14 +++++++++++++- capacitor.config.ts | 17 ++++++++++++++++- coach-ios.local.json.example | 3 +++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 coach-ios.local.json.example diff --git a/.gitignore b/.gitignore index 47ca577..37f6dfd 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ ios/App/public/ # Secrets .env .env.local +coach-ios.local.json *.p8 *.p12 *.mobileprovision diff --git a/README.md b/README.md index f4a3489..e04981a 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,23 @@ Le code web n'est pas embarqué — l'app pointe vers la prod via `server.url` d ### 1. Cloner le repo sur le Mac mini ```bash -git clone git@gitea:sylvain/coach-ios.git +git clone https://git.nexus.hypnotruck.ch/sylvain/coach-ios.git cd coach-ios npm install ``` +### 1bis. Configurer le token d'auth (auto-login) + +Le repo ne contient **pas** le token `COACH_WEB_TOKEN` (gitignored). Crée le fichier sur le Mac : + +```bash +cp coach-ios.local.json.example coach-ios.local.json +# Édite coach-ios.local.json et remplace par la vraie valeur +# (visible dans ~/.config/infomaniak.env sur le VPS, ligne export COACH_WEB_TOKEN=) +``` + +L'app utilisera ce token pour se connecter automatiquement à `coach.hypnotruck.ch/login?token=...` au lancement. + ### 2. Générer les icônes & splash ```bash diff --git a/capacitor.config.ts b/capacitor.config.ts index 58e2696..4b99874 100644 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -1,4 +1,19 @@ import type { CapacitorConfig } from '@capacitor/cli'; +import { readFileSync, existsSync } from 'fs'; +import { resolve } from 'path'; + +// Token d'auth coach.hypnotruck.ch chargé depuis coach-ios.local.json (gitignored). +// Sur le Mac mini : créer ce fichier avec { "coachWebToken": "..." } avant de builder. +const localConfigPath = resolve(__dirname, 'coach-ios.local.json'); +const localConfig = existsSync(localConfigPath) + ? JSON.parse(readFileSync(localConfigPath, 'utf-8')) + : {}; +const coachWebToken: string = localConfig.coachWebToken || ''; + +const baseUrl = 'https://coach.hypnotruck.ch'; +const startUrl = coachWebToken + ? `${baseUrl}/login?token=${encodeURIComponent(coachWebToken)}` + : baseUrl; const config: CapacitorConfig = { appId: 'ch.hypnotruck.coach', @@ -6,7 +21,7 @@ const config: CapacitorConfig = { webDir: 'www', server: { - url: 'https://coach.hypnotruck.ch', + url: startUrl, cleartext: false, androidScheme: 'https', }, diff --git a/coach-ios.local.json.example b/coach-ios.local.json.example new file mode 100644 index 0000000..c28e9d8 --- /dev/null +++ b/coach-ios.local.json.example @@ -0,0 +1,3 @@ +{ + "coachWebToken": "REMPLACE_PAR_LA_VALEUR_DE_COACH_WEB_TOKEN" +}