Auto-login via token coach_web_token au lancement

- 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
This commit is contained in:
Sylvain Bettinelli
2026-05-05 19:15:59 +00:00
parent 1d82ec8b10
commit 3e71dbe3a3
4 changed files with 33 additions and 2 deletions

View File

@@ -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',
},