Support Google Services based sign-in config
This commit is contained in:
@@ -30,7 +30,7 @@ class _AccountsPageState extends State<AccountsPage> {
|
||||
final googleSignIn = GoogleSignIn.instance;
|
||||
List<GoogleCalendarInfo> googleCalendars = [];
|
||||
GoogleSignInAccount? signedInAccount;
|
||||
String runtimeServerClientId = googleCalendarServerClientId;
|
||||
String? runtimeServerClientId;
|
||||
bool initialized = false;
|
||||
bool loadingCalendars = false;
|
||||
bool syncing = false;
|
||||
@@ -53,16 +53,7 @@ class _AccountsPageState extends State<AccountsPage> {
|
||||
|
||||
final configuredClientId = await _loadGoogleServerClientId();
|
||||
if (!mounted) return;
|
||||
if (configuredClientId == null || configuredClientId.trim().isEmpty) {
|
||||
setState(() {
|
||||
loadingCalendars = false;
|
||||
statusMessage =
|
||||
'A Google napt\u00e1rkapcsolat m\u00e9g nincs bek\u00f6tve. A csal\u00e1dtagoknak nem kell client ID-t megadniuk; a JARVIS admin fel\u00fcleten kell egyszer be\u00e1ll\u00edtani a Google Calendar OAuth azonos\u00edt\u00f3t.';
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
runtimeServerClientId = configuredClientId.trim();
|
||||
runtimeServerClientId = configuredClientId?.trim();
|
||||
await _initializeGoogle();
|
||||
}
|
||||
|
||||
@@ -121,7 +112,10 @@ class _AccountsPageState extends State<AccountsPage> {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
loadingCalendars = false;
|
||||
statusMessage = 'Google inicializ\u00e1l\u00e1s nem siker\u00fclt: $error';
|
||||
statusMessage = _friendlyGoogleError(
|
||||
'Google inicializ\u00e1l\u00e1s nem siker\u00fclt',
|
||||
error,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -163,17 +157,30 @@ class _AccountsPageState extends State<AccountsPage> {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
loadingCalendars = false;
|
||||
statusMessage = 'Google bejelentkez\u00e9s nem siker\u00fclt: $error';
|
||||
statusMessage = _friendlyGoogleError(
|
||||
'Google bejelentkez\u00e9s nem siker\u00fclt',
|
||||
error,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
String _friendlyGoogleError(String prefix, Object error) {
|
||||
final raw = error.toString();
|
||||
if (raw.contains('serverClientId must be provided') ||
|
||||
raw.contains('CredentialManager requires a serverClientId')) {
|
||||
return '$prefix: hi\u00e1nyzik az app Google konfigur\u00e1ci\u00f3ja. '
|
||||
'A bel\u00e9p\u00e9si ablakos m\u0171k\u00f6d\u00e9shez tedd be az android/app/google-services.json f\u00e1jlt, '
|
||||
'amely tartalmaz Web application OAuth client ID-t, majd buildeld \u00fajra az APK-t.';
|
||||
}
|
||||
return '$prefix: $raw';
|
||||
}
|
||||
|
||||
Future<void> _ensureGoogleInitialized() async {
|
||||
final clientId = runtimeServerClientId.trim();
|
||||
if (clientId.isEmpty) {
|
||||
throw Exception(
|
||||
'A Google napt\u00e1rkapcsolat m\u00e9g nincs bek\u00f6tve.',
|
||||
);
|
||||
final clientId = runtimeServerClientId;
|
||||
if (clientId == null || clientId.isEmpty) {
|
||||
await googleSignIn.initialize();
|
||||
return;
|
||||
}
|
||||
|
||||
await googleSignIn.initialize(
|
||||
|
||||
Reference in New Issue
Block a user