mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-09-28 03:51:43 +02:00
handle async browser login better
This commit is contained in:
@@ -30,18 +30,20 @@ class AuthSection extends StatelessWidget {
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
if (appState.isLoggedIn) {
|
if (appState.isLoggedIn) {
|
||||||
await appState.logout();
|
await appState.logout();
|
||||||
|
if (context.mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(locService.t('auth.loggedOut')),
|
||||||
|
backgroundColor: Colors.grey,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Start login flow - the user will be redirected to browser
|
||||||
await appState.forceLogin();
|
await appState.forceLogin();
|
||||||
}
|
|
||||||
if (context.mounted) {
|
// Don't show immediate feedback - the UI will update automatically
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
// when the OAuth callback completes and notifyListeners() is called
|
||||||
SnackBar(
|
|
||||||
content: Text(appState.isLoggedIn
|
|
||||||
? locService.t('auth.loggedInAs', params: [appState.username])
|
|
||||||
: locService.t('auth.loggedOut')),
|
|
||||||
backgroundColor: appState.isLoggedIn ? Colors.green : Colors.grey,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user