Compare commits
6
Commits
0615dc6421
...
v0.6.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
640bbea802 | ||
|
|
7ae137f865 | ||
|
|
cabd121ac1 | ||
|
|
dbbe2171c2 | ||
|
|
09952e4dc1 | ||
|
|
c7990b0971 |
No files matched your search
@@ -169,3 +169,4 @@ cython_debug/
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
strix_runs/*
|
||||
@@ -0,0 +1 @@
|
||||
docs/superpowers/specs/*.md
|
||||
@@ -40,7 +40,7 @@ repos:
|
||||
rev: v0.13.0
|
||||
hooks:
|
||||
- id: markdownlint
|
||||
exclude: "^.github|(^docs/_sidebar\\.md$)"
|
||||
exclude: "^.github|_sidebar\\.md$|superpowers/(specs|plans)/.*\\.md$"
|
||||
|
||||
- repo: https://github.com/shellcheck-py/shellcheck-py
|
||||
rev: v0.11.0.1
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,350 @@
|
||||
<!-- markdownlint-disable-file -->
|
||||
# MyIce Flutter App - Design Specification
|
||||
|
||||
**Date:** 2026-07-06
|
||||
**Context:** Application mobile Flutter (iOS/Android) reproduisant le fonctionnement de la webapp myice existante.
|
||||
**Backend:** L'application se connecte a l'API FastAPI existante (myice/webapi.py) via HTTP.
|
||||
|
||||
## 1. Architecture globale
|
||||
|
||||
Approche : **Repository + Provider (B)**
|
||||
|
||||
```
|
||||
lib/
|
||||
├── main.dart # Entry point, MaterialApp, MultiProvider
|
||||
├── config/
|
||||
│ └── api_config.dart # URL base de l'API, timeouts
|
||||
├── models/
|
||||
│ ├── account.dart # {name, label}
|
||||
│ ├── event.dart # Game/Practice du schedule
|
||||
│ ├── event_detail.dart # Details + convocation
|
||||
│ ├── user_info.dart # {email}
|
||||
│ └── convocation.dart # Player, Staff, Convocation
|
||||
├── services/
|
||||
│ ├── api_service.dart # Dio + intercepteur Bearer
|
||||
│ └── auth_service.dart # Login/logout OIDC, deep link
|
||||
├── providers/
|
||||
│ ├── auth_provider.dart # Etat auth + user info
|
||||
│ ├── schedule_provider.dart # Liste events + filtres
|
||||
│ └── event_provider.dart # Details d'un event (optionnel)
|
||||
├── repositories/
|
||||
│ └── myice_repository.dart # Appels API : accounts, schedule, game
|
||||
├── screens/
|
||||
│ ├── login_screen.dart
|
||||
│ ├── schedule_screen.dart
|
||||
│ └── event_detail_screen.dart
|
||||
└── widgets/
|
||||
├── event_card.dart
|
||||
├── filter_dropdown.dart
|
||||
└── loading_indicator.dart
|
||||
```
|
||||
|
||||
**Pattern :** Repository encapsule les appels API -> Providers gerent l'etat reactif -> Screens ecoutent les Providers.
|
||||
|
||||
## 2. Dependances Flutter
|
||||
|
||||
```yaml
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
dio: ^5.4.0
|
||||
provider: ^6.1.0
|
||||
shared_preferences: ^2.2.0
|
||||
flutter_web_auth: ^0.6.0
|
||||
intl: ^0.19.0 # Pour le parsing/formatage de dates si besoin
|
||||
```
|
||||
|
||||
## 3. Modeles de donnees (JSON <-> Dart)
|
||||
|
||||
### Account
|
||||
```dart
|
||||
class Account {
|
||||
final String name;
|
||||
final String label;
|
||||
Account({required this.name, required this.label});
|
||||
factory Account.fromJson(Map<String, dynamic> json) => Account(
|
||||
name: json['name'] as String,
|
||||
label: json['label'] as String,
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Event
|
||||
Provenant de `/schedule`.
|
||||
```dart
|
||||
class Event {
|
||||
final String idEvent;
|
||||
final String agegroup;
|
||||
final String name;
|
||||
final String title;
|
||||
final String opponent;
|
||||
final String place;
|
||||
final String start;
|
||||
final String end;
|
||||
final String? color;
|
||||
final String eventType; // mappe depuis le champ JSON 'event'
|
||||
|
||||
Event({
|
||||
required this.idEvent,
|
||||
required this.agegroup,
|
||||
required this.name,
|
||||
required this.title,
|
||||
required this.opponent,
|
||||
required this.place,
|
||||
required this.start,
|
||||
required this.end,
|
||||
this.color,
|
||||
required this.eventType,
|
||||
});
|
||||
|
||||
factory Event.fromJson(Map<String, dynamic> json) => Event(
|
||||
idEvent: json['id_event']?.toString() ?? '',
|
||||
agegroup: json['agegroup'] as String,
|
||||
name: json['name'] as String? ?? '',
|
||||
title: json['title'] as String,
|
||||
opponent: json['opponent'] as String? ?? '',
|
||||
place: json['place'] as String? ?? '',
|
||||
start: json['start'] as String,
|
||||
end: json['end'] as String,
|
||||
color: json['color'] as String?,
|
||||
eventType: json['event'] as String? ?? '',
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Player
|
||||
```dart
|
||||
class Player {
|
||||
final String? position;
|
||||
final String? number;
|
||||
final String fname;
|
||||
final String lname;
|
||||
final String dob;
|
||||
|
||||
Player({this.position, this.number, required this.fname, required this.lname, required this.dob});
|
||||
|
||||
factory Player.fromJson(Map<String, dynamic> json) => Player(
|
||||
position: json['position'] as String?,
|
||||
number: json['number']?.toString(),
|
||||
fname: json['fname'] as String,
|
||||
lname: json['lname'] as String,
|
||||
dob: json['dob'] as String,
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Staff
|
||||
```dart
|
||||
class Staff {
|
||||
final String role;
|
||||
final String fname;
|
||||
final String lname;
|
||||
|
||||
Staff({required this.role, required this.fname, required this.lname});
|
||||
|
||||
factory Staff.fromJson(Map<String, dynamic> json) => Staff(
|
||||
role: json['role'] as String,
|
||||
fname: json['fname'] as String,
|
||||
lname: json['lname'] as String,
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Convocation
|
||||
```dart
|
||||
class Convocation {
|
||||
final List<Player> available;
|
||||
final List<Staff> staff;
|
||||
|
||||
Convocation({required this.available, required this.staff});
|
||||
|
||||
factory Convocation.fromJson(Map<String, dynamic> json) => Convocation(
|
||||
available: (json['available'] as List? ?? [])
|
||||
.map((e) => Player.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
staff: (json['staff'] as List? ?? [])
|
||||
.map((e) => Staff.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### EventDetail
|
||||
Provenant de `/game/{id}`.
|
||||
```dart
|
||||
class EventDetail {
|
||||
final String title;
|
||||
final String type;
|
||||
final String place;
|
||||
final String timeStart;
|
||||
final String timeEnd;
|
||||
final Convocation convocation;
|
||||
|
||||
EventDetail({
|
||||
required this.title,
|
||||
required this.type,
|
||||
required this.place,
|
||||
required this.timeStart,
|
||||
required this.timeEnd,
|
||||
required this.convocation,
|
||||
});
|
||||
|
||||
factory EventDetail.fromJson(Map<String, dynamic> json) => EventDetail(
|
||||
title: json['title'] as String,
|
||||
type: json['type'] as String,
|
||||
place: json['place'] as String? ?? '',
|
||||
timeStart: json['time_start'] as String,
|
||||
timeEnd: json['time_end'] as String,
|
||||
convocation: Convocation.fromJson(json['convocation'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### UserInfo
|
||||
```dart
|
||||
class UserInfo {
|
||||
final String email;
|
||||
UserInfo({required this.email});
|
||||
factory UserInfo.fromJson(Map<String, dynamic> json) => UserInfo(
|
||||
email: json['email'] as String? ?? '',
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## 4. Services
|
||||
|
||||
### ApiService
|
||||
Utilise `dio`. Un intercepteur ajoute automatiquement le header `Authorization: Bearer <token>`.
|
||||
|
||||
Concept:
|
||||
- `setBearerToken(token)` ajoute un `InterceptorsWrapper` a Dio.
|
||||
- `clearBearerToken()` retire les intercepteurs existants.
|
||||
- Methodes: `getAccounts()`, `getSchedule(account)`, `getGameDetail(gameId, account)`, `getUserInfo()`.
|
||||
- Retournent des objets modeles via `fromJson`.
|
||||
|
||||
### AuthService
|
||||
Utilise `flutter_web_auth` pour l'OIDC + `shared_preferences` pour stocker le token.
|
||||
|
||||
Concept:
|
||||
- `storedToken`, `storedAccount` depuis `SharedPreferences`.
|
||||
- `login()`: appelle `FlutterWebAuth.authenticate(url: baseUrl/login, callbackUrlScheme: 'myice')`. Parse le fragment `#access_token=xxx` de l'URL retournee. Stocke le token.
|
||||
- `setAccount(account)`: persiste le compte selectionne.
|
||||
- `logout()`: supprime token, account, userInfo des prefs.
|
||||
|
||||
**Configuration deep link requise:**
|
||||
- Android: intent-filter dans `AndroidManifest.xml` pour scheme `myice://`.
|
||||
- iOS: `CFBundleURLTypes` dans `Info.plist` avec scheme `myice`.
|
||||
|
||||
## 5. Providers (Provider package)
|
||||
|
||||
### AuthProvider
|
||||
Gere l'etat global d'authentification.
|
||||
|
||||
**Etat:** `isAuthenticated`, `userInfo`.
|
||||
**Methodes:**
|
||||
- `init()`: Verifie token stocke, appelle `/userinfo`. Si 401, considere deconnecte.
|
||||
- `login()`: Lance AuthService.login(), met a jour le token, appelle `/userinfo`, notifie listeners.
|
||||
- `logout()`: Efface le token, notifie listeners.
|
||||
|
||||
### ScheduleProvider
|
||||
Gere les events, les comptes, et les filtres.
|
||||
|
||||
**Etat:** `accounts`, `events`, `selectedAccount`, `selectedAgegroup`, `selectedSubgroup`, `isLoading`, `error`.
|
||||
**Methodes:**
|
||||
- `loadAccounts()`: Appelle `/accounts`, met a jour `accounts`. Selectionne `storedAccount` si present, sinon le premier.
|
||||
- `loadSchedule()`: Met `isLoading = true`, appelle `/schedule?account=selectedAccount`, filtre events ou `eventType == "Jeu"`, extrait les `agegroup` uniques pour les filtres.
|
||||
- `setAccount(String)`: Met a jour `selectedAccount`, sauvegarde dans SharedPreferences, appelle `loadSchedule()`.
|
||||
- `setAgegroup(String)`: Met a jour, reset `selectedSubgroup`, notifie.
|
||||
- `setSubgroup(String)`: Met a jour, notifie.
|
||||
- `get filteredEvents`: Getter filtre `events` par `agegroup` et `subgroup`.
|
||||
|
||||
**Logique de filtre sous-groupe:**
|
||||
Identique a la webapp. La fonction `extractSubgroup(name)` retire la partie apres `" - "` dans le `name` de l'event pour obtenir le sous-groupe (si applicable).
|
||||
|
||||
### EventDetailProvider (Optionnel)
|
||||
Gere le chargement des details d'un event. Peut etre integre dans `ScheduleProvider` si prefere pour garder un seul provider.
|
||||
|
||||
**Etat:** `eventDetail`, `isLoading`, `error`.
|
||||
**Methodes:** `loadEventDetail(gameId)` appelle `/game/{gameId}`.
|
||||
|
||||
## 6. Ecrans
|
||||
|
||||
### LoginScreen
|
||||
- **AppBar:** Aucune (centre).
|
||||
- **Body:** Column centree.
|
||||
- Titre: "MyIce - Games" (headlineLarge, couleur indigo).
|
||||
- Bouton: "Se connecter avec Infomaniak" (style degrade indigo -> violet).
|
||||
- Texte d'aide: "Connectez-vous pour acceder aux evenements...".
|
||||
- **Comportement:**
|
||||
- Si `authProvider.isAuthenticated`, navigue automatiquement vers `ScheduleScreen`.
|
||||
- Affiche `CircularProgressIndicator` pendant le login.
|
||||
- SnackBar en cas d'erreur.
|
||||
|
||||
### ScheduleScreen
|
||||
- **AppBar:** Titre "MyIce", action logout + email utilisateur.
|
||||
- **Body:**
|
||||
- **Filtres:** Card avec 3 `DropdownButtonFormField` (Compte, Age, Sous-groupe). Le bouton "Charger" est optionnel (changement de compte recharge auto).
|
||||
- **Liste:** `Expanded` + `ListView.builder`. Affiche `EventCard` pour chaque event filtre.
|
||||
- Etats: Loading (`CircularProgressIndicator`), vide (texte info), erreur (SnackBar).
|
||||
|
||||
### EventDetailScreen
|
||||
- **AppBar:** Titre = `event.title`, bouton retour.
|
||||
- **Body:** `SingleChildScrollView` + `Padding(16)`.
|
||||
- Card recap: Type, Lieu, Heure.
|
||||
- Section Joueurs:
|
||||
- Si vide: Card amber "Aucun joueur convoque".
|
||||
- Sinon: Card avec total + repartition positions. Liste triee par position puis numero: `[Position] #Num - Prenom Nom (DOB)`.
|
||||
- Section Personnel:
|
||||
- Si vide: Card bleu "Aucun personnel convoque".
|
||||
- Sinon: Liste `role: Prenom Nom`.
|
||||
- Si aucun joueur ET aucun personnel: Card amber principal "Aucun joueur ni personnel convoque" uniquement.
|
||||
|
||||
### Widgets reutilisables
|
||||
- **EventCard:** Card avec bordure laterale coloree. Titre (`agegroup - name`), sous-titre, details (adversaire, lieu, heure). onTap -> `EventDetailScreen`.
|
||||
- **FilterDropdown:** `DropdownButtonFormField` generique stylise.
|
||||
|
||||
## 7. Navigation & Routing
|
||||
|
||||
Utilisation de `Navigator` classique (pas de package tierce pour 3 ecrans).
|
||||
- `main.dart`: `MaterialApp` avec `home` determine par `Consumer<AuthProvider>` (`ScheduleScreen` ou `LoginScreen`).
|
||||
- Navigation details: `Navigator.push(MaterialPageRoute(builder: (_) => EventDetailScreen(...)))`.
|
||||
|
||||
## 8. Gestion des erreurs
|
||||
|
||||
- Erreur reseau / API: SnackBar rouge avec message.
|
||||
- 401 (Token expire): Deconnexion automatique + redirection `LoginScreen`.
|
||||
- JSON malforme: La webapp gere cote backend. Cote Flutter, `jsonDecode` echoue -> message "Donnees invalides".
|
||||
- Aucun event/joueur: Interface vide avec message informatif (pas d'erreur).
|
||||
|
||||
## 9. Configuration requise
|
||||
|
||||
### Android
|
||||
Ajouter un intent-filter dans `android/app/src/main/AndroidManifest.xml` pour le deep link `myice://callback`.
|
||||
|
||||
### iOS
|
||||
Ajouter `CFBundleURLTypes` dans `ios/Runner/Info.plist` avec scheme `myice`.
|
||||
|
||||
### Configuration API
|
||||
`lib/config/api_config.dart`:
|
||||
```dart
|
||||
class ApiConfig {
|
||||
static const String baseUrl = 'https://your-api-domain.com'; // A configurer
|
||||
}
|
||||
```
|
||||
|
||||
## 10. Plan d'implementation (High-level)
|
||||
|
||||
1. Scaffolding du projet Flutter (`flutter create`).
|
||||
2. Ajout des dependances (`pubspec.yaml`).
|
||||
3. Configuration des deep links (`AndroidManifest` + `Info.plist`).
|
||||
4. Implementation des modeles de donnees (`fromJson`).
|
||||
5. Implementation des services (`ApiService`, `AuthService`).
|
||||
6. Implementation des providers (`AuthProvider`, `ScheduleProvider`).
|
||||
7. Implementation des ecrans (`LoginScreen`, `ScheduleScreen`, `EventDetailScreen`).
|
||||
8. Implementation des widgets (`EventCard`, etc.).
|
||||
9. Wiring dans `main.dart` avec `MultiProvider`.
|
||||
10. Tests manuels de l'auth OIDC et de la navigation.
|
||||
|
||||
---
|
||||
|
||||
**Prochaine etape apres validation du spec:** Creer le plan d'implementation detaille avec le skill `writing-plans`.
|
||||
+24
-21
@@ -594,16 +594,16 @@ mobile_headers = {
|
||||
}
|
||||
|
||||
|
||||
def curl_for_mobile_login(username: str, password: str) -> str:
|
||||
"""Generate curl command to replicate mobile_login request."""
|
||||
import base64
|
||||
# def curl_for_mobile_login(username: str, password: str) -> str:
|
||||
# """Generate curl command to replicate mobile_login request."""
|
||||
# import base64
|
||||
|
||||
headers_str = " ".join([f"-H '{k}: {v}'" for k, v in mobile_headers.items()])
|
||||
encoded_username = base64.b64encode(username.encode()).decode()
|
||||
encoded_password = base64.b64encode(password.encode()).decode()
|
||||
return f"""curl -X POST "https://app.myice.hockey/api/mobilerest/login" \
|
||||
{headers_str} \
|
||||
-d 'login_email={encoded_username}&login_password={encoded_password}&language=FR&v=2'"""
|
||||
# headers_str = " ".join([f"-H '{k}: {v}'" for k, v in mobile_headers.items()])
|
||||
# encoded_username = base64.b64encode(username.encode()).decode()
|
||||
# encoded_password = base64.b64encode(password.encode()).decode()
|
||||
# return f"""curl -X POST "https://app.myice.hockey/api/mobilerest/login" \
|
||||
# {headers_str} \
|
||||
# -d 'login_email={encoded_username}&login_password={encoded_password}&language=FR&v=2'"""
|
||||
|
||||
|
||||
def mobile_login(config_section: str | None = None):
|
||||
@@ -619,7 +619,7 @@ def mobile_login(config_section: str | None = None):
|
||||
|
||||
print("Requesting token", file=sys.stderr)
|
||||
# Print curl equivalent for debugging
|
||||
print(curl_for_mobile_login(username, password), file=sys.stderr)
|
||||
# print(curl_for_mobile_login(username, password), file=sys.stderr)
|
||||
with requests.post(
|
||||
"https://app.myice.hockey/api/mobilerest/login",
|
||||
headers=mobile_headers,
|
||||
@@ -643,23 +643,26 @@ userdata = {
|
||||
}
|
||||
|
||||
|
||||
def curl_for_refresh_data(token: str, club_id: int) -> str:
|
||||
"""Generate curl command to replicate refresh_data request."""
|
||||
headers_str = " ".join([f"-H '{k}: {v}'" for k, v in mobile_headers.items()])
|
||||
return f"""curl -X POST "https://app.myice.hockey/api/mobilerest/refreshdata" \
|
||||
{headers_str} \
|
||||
-d 'token={token}&id_club={club_id}&language=FR'"""
|
||||
# def curl_for_refresh_data(token: str, club_id: int) -> str:
|
||||
# """Generate curl command to replicate refresh_data request."""
|
||||
# headers_str = " ".join([f"-H '{k}: {v}'" for k, v in mobile_headers.items()])
|
||||
# return f"""curl -X POST "https://app.myice.hockey/api/mobilerest/refreshdata" \
|
||||
# {headers_str} \
|
||||
# -d 'token={token}&id_club={club_id}&language=FR'"""
|
||||
|
||||
|
||||
def refresh_data():
|
||||
def refresh_data(user_data=None):
|
||||
# Use provided user_data or fall back to global userdata for backward compatibility
|
||||
if user_data is None:
|
||||
user_data = userdata
|
||||
# Print curl equivalent for debugging
|
||||
print(
|
||||
curl_for_refresh_data(userdata["token"], userdata["id_club"]), file=sys.stderr
|
||||
)
|
||||
# print(
|
||||
# curl_for_refresh_data(user_data["token"], user_data["id_club"]), file=sys.stderr
|
||||
# )
|
||||
with requests.post(
|
||||
"https://app.myice.hockey/api/mobilerest/refreshdata",
|
||||
headers=mobile_headers,
|
||||
data=f"token={userdata['token']}&id_club={userdata['id_club']}&language=FR",
|
||||
data=f"token={user_data['token']}&id_club={user_data['id_club']}&language=FR",
|
||||
# verify=False,
|
||||
) as r:
|
||||
r.raise_for_status()
|
||||
|
||||
+33
-19
@@ -7,7 +7,7 @@ from fastapi import FastAPI, Header, HTTPException, Request, status
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import FileResponse, RedirectResponse
|
||||
from pydantic import BaseModel
|
||||
from typing import Annotated
|
||||
from typing import Annotated, Optional
|
||||
from . import myice
|
||||
|
||||
# OIDC Configuration
|
||||
@@ -151,11 +151,10 @@ async def favico():
|
||||
|
||||
|
||||
@app.get("/login")
|
||||
async def login(request: Request):
|
||||
async def login(request: Request, redirect_uri: Optional[str] = None):
|
||||
"""Redirect to Infomaniak OIDC login"""
|
||||
import urllib.parse
|
||||
|
||||
import secrets
|
||||
import urllib.parse
|
||||
|
||||
state = secrets.token_urlsafe(32)
|
||||
nonce = secrets.token_urlsafe(32)
|
||||
@@ -196,6 +195,16 @@ async def login(request: Request):
|
||||
samesite="Lax",
|
||||
max_age=300,
|
||||
)
|
||||
# Store target redirect URI (e.g. myice://callback) for mobile app flow
|
||||
if redirect_uri:
|
||||
response.set_cookie(
|
||||
"oidc_target_redirect",
|
||||
redirect_uri,
|
||||
httponly=True,
|
||||
secure=True,
|
||||
samesite="Lax",
|
||||
max_age=300,
|
||||
)
|
||||
return response
|
||||
|
||||
|
||||
@@ -204,12 +213,17 @@ async def callback(request: Request, code: str, state: str):
|
||||
"""Handle OIDC callback and exchange code for token"""
|
||||
expected_state = request.cookies.get("oidc_state")
|
||||
code_verifier = request.cookies.get("oidc_verifier")
|
||||
# Determine final redirect target (mobile app or web frontend)
|
||||
target_redirect = request.cookies.get("oidc_target_redirect") or os.environ.get(
|
||||
"FRONTEND_URL", "/"
|
||||
)
|
||||
# We should also delete state/nonce cookies once read
|
||||
if not expected_state or state != expected_state:
|
||||
response = RedirectResponse("/?error=Invalid state parameter")
|
||||
response = RedirectResponse(f"/{target_redirect}?error=Invalid state parameter")
|
||||
response.delete_cookie("oidc_state")
|
||||
response.delete_cookie("oidc_nonce")
|
||||
response.delete_cookie("oidc_verifier")
|
||||
response.delete_cookie("oidc_target_redirect")
|
||||
return response
|
||||
# Exchange authorization code for access token
|
||||
token_data = {
|
||||
@@ -227,14 +241,14 @@ async def callback(request: Request, code: str, state: str):
|
||||
# Log the error for debugging
|
||||
logging.error("Token exchange failed: %s", token_response)
|
||||
# Redirect back to frontend with error
|
||||
frontend_url = os.environ.get("FRONTEND_URL", "/")
|
||||
error_detail = token_response.get(
|
||||
"error_description", "Failed to obtain access token"
|
||||
)
|
||||
error_response = RedirectResponse(f"{frontend_url}?error={error_detail}")
|
||||
error_response = RedirectResponse(f"{target_redirect}?error={error_detail}")
|
||||
error_response.delete_cookie("oidc_state")
|
||||
error_response.delete_cookie("oidc_nonce")
|
||||
error_response.delete_cookie("oidc_verifier")
|
||||
error_response.delete_cookie("oidc_target_redirect")
|
||||
return error_response
|
||||
|
||||
access_token = token_response["access_token"]
|
||||
@@ -250,19 +264,19 @@ async def callback(request: Request, code: str, state: str):
|
||||
user_email = userinfo.get("email")
|
||||
if ALLOWED_USERS and user_email not in ALLOWED_USERS:
|
||||
# Redirect back to frontend with error
|
||||
frontend_url = os.environ.get("FRONTEND_URL", "/")
|
||||
response = RedirectResponse(f"{frontend_url}?error=User not authorized")
|
||||
response = RedirectResponse(f"{target_redirect}?error=User not authorized")
|
||||
response.delete_cookie("oidc_state")
|
||||
response.delete_cookie("oidc_nonce")
|
||||
response.delete_cookie("oidc_verifier")
|
||||
response.delete_cookie("oidc_target_redirect")
|
||||
return response
|
||||
|
||||
# Redirect back to frontend with access token and user info
|
||||
frontend_url = os.environ.get("FRONTEND_URL", "/")
|
||||
response = RedirectResponse(f"{frontend_url}#access_token={access_token}")
|
||||
response = RedirectResponse(f"{target_redirect}#access_token={access_token}")
|
||||
response.delete_cookie("oidc_state")
|
||||
response.delete_cookie("oidc_nonce")
|
||||
response.delete_cookie("oidc_verifier")
|
||||
response.delete_cookie("oidc_target_redirect")
|
||||
return response
|
||||
|
||||
|
||||
@@ -352,15 +366,15 @@ async def schedule(
|
||||
|
||||
try:
|
||||
if existing_token:
|
||||
myice.userdata = {
|
||||
user_data = {
|
||||
"id": userid,
|
||||
"id_club": club_id or 186,
|
||||
"token": existing_token,
|
||||
}
|
||||
else:
|
||||
myice.userdata = myice.mobile_login(config_section=account)
|
||||
user_data = myice.mobile_login(config_section=account)
|
||||
|
||||
data = myice.refresh_data()
|
||||
data = myice.refresh_data(user_data=user_data)
|
||||
if "club_games" in data:
|
||||
return data["club_games"]
|
||||
else:
|
||||
@@ -433,13 +447,13 @@ async def game(
|
||||
config_section=account
|
||||
)
|
||||
if existing_token:
|
||||
myice.userdata = {
|
||||
user_data = {
|
||||
"id": userid,
|
||||
"id_club": club_id or 186,
|
||||
"token": existing_token,
|
||||
}
|
||||
else:
|
||||
myice.userdata = myice.mobile_login(config_section=account)
|
||||
user_data = myice.mobile_login(config_section=account)
|
||||
|
||||
# data = refresh_data()
|
||||
with requests.post(
|
||||
@@ -447,11 +461,11 @@ async def game(
|
||||
headers=myice.mobile_headers,
|
||||
data="&".join(
|
||||
[
|
||||
f"token={myice.userdata['token']}",
|
||||
f"token={user_data['token']}",
|
||||
f"id_event={game_id}",
|
||||
"type=games",
|
||||
f"id_player={myice.userdata['id']}",
|
||||
f"id_club={myice.userdata['id_club']}",
|
||||
f"id_player={user_data['id']}",
|
||||
f"id_club={user_data['id_club']}",
|
||||
"language=FR",
|
||||
]
|
||||
),
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# Flutter/Dart specific
|
||||
.dart_tool/
|
||||
.packages
|
||||
build/
|
||||
.pub/
|
||||
|
||||
# IDEs
|
||||
.idea/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
*.ctxt
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# Android
|
||||
*.apk
|
||||
*.ap_
|
||||
*.aab
|
||||
!/android/app/src/main/AndroidManifest.xml
|
||||
|
||||
# iOS
|
||||
ios/Pods/
|
||||
ios/.symlinks/
|
||||
ios/Flutter/Flutter.framework
|
||||
ios/Flutter/Flutter.podspec
|
||||
|
||||
# Xcode
|
||||
xcuserdata/
|
||||
*.xcworkspace/
|
||||
DerivedData/
|
||||
|
||||
# Web
|
||||
lib/generated_plugin_registrant.dart
|
||||
|
||||
# Windows
|
||||
windows/flutter/
|
||||
windows/runner/
|
||||
|
||||
# Linux
|
||||
linux/flutter/
|
||||
linux/runner/
|
||||
|
||||
# Firebase
|
||||
firebase_app_id_file.json
|
||||
|
||||
# Coverage
|
||||
coverage/
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.swp
|
||||
*~
|
||||
@@ -0,0 +1,33 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application
|
||||
android:label="myice_mobile"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="myice" android:host="callback" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>MyIce</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>myice_mobile</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(FLUTTER_BUILD_NAME)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>ch.parano.myice</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>myice</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
name: myice_mobile
|
||||
description: Flutter mobile app for MyIce
|
||||
publish_to: 'none'
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: '>=3.1.0 <4.0.0'
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
dio: ^5.4.0
|
||||
provider: ^6.1.0
|
||||
shared_preferences: ^2.2.0
|
||||
flutter_web_auth: ^0.6.0
|
||||
intl: ^0.19.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^3.0.0
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
Reference in new issue
Block a user