Skip to content

Commit

Permalink
Merge branch 'main' into feature/full-esp32-firmware-compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mediocre9 authored Jul 31, 2024
2 parents 0470252 + 437fb32 commit 43dab19
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
9 changes: 4 additions & 5 deletions lib/screens/bluetooth_home_screen/bluetooth_home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ class _BluetoothHomeScreenState extends State<BluetoothHomeScreen>
void initState() {
super.initState();
widget.authService.isRevoked().then((blocked) {
log(blocked.toString());
if (blocked) {
Navigator.pushNamedAndRemoveUntil(
Navigator.pushReplacementNamed(
context,
AppRoutes.auth,
(context) => false,
);
} else {
context.read<BluetoothHomeCubit>().init();
}
});

context.read<BluetoothHomeCubit>().init();

_animationController = AnimationController(
vsync: this,
duration: 1200.ms,
Expand All @@ -50,7 +50,6 @@ class _BluetoothHomeScreenState extends State<BluetoothHomeScreen>
actions: [
BlocBuilder<BluetoothHomeCubit, BluetoothHomeState>(
builder: (context, state) {
log(state.runtimeType.toString());
switch (state) {
case Initial() || LoadedDevices():
return const StartScanButtonWidget();
Expand Down
3 changes: 1 addition & 2 deletions lib/screens/wifi_home_screen/wifi_home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ class _WifiHomeScreenState extends State<WifiHomeScreen>
super.initState();
widget.authService.isRevoked().then((blocked) {
if (blocked) {
Navigator.pushNamedAndRemoveUntil(
Navigator.pushReplacementNamed(
context,
AppRoutes.auth,
(context) => false,
);
}
});
Expand Down
19 changes: 12 additions & 7 deletions lib/services/auth_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,21 @@ class GoogleAuthService implements IAuthenticationService {

@override
Future<bool> isRevoked() async {
if (await _connectivityService.isOffline()) return false;
try {
await for (final user in FirebaseAuth.instance.authStateChanges()) {
if (user == null) return true;
IdTokenResult result = await user.getIdTokenResult(true);
return result.token == null;
final user = FirebaseAuth.instance.currentUser;
if (user == null) {
return true;
}
} catch (e) {

if (await _connectivityService.isOffline()) {
return false;
}

IdTokenResult result = await user.getIdTokenResult(true);
return result.token == null;
} on Exception catch (e) {
log(e.toString());
return true;
}
return false;
}
}

0 comments on commit 43dab19

Please sign in to comment.