if staging user tries to login to production (or vice versa), log them out

This commit is contained in:
ggurdin 2024-10-25 10:46:50 -04:00
parent 54975adbb3
commit cd5f2379b8
No known key found for this signature in database
GPG key ID: A01CB41737CBB478

View file

@ -1,5 +1,6 @@
import 'package:collection/collection.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pangea/config/environment.dart';
import 'package:fluffychat/pangea/controllers/language_list_controller.dart';
import 'package:fluffychat/pangea/utils/error_handler.dart';
import 'package:fluffychat/pangea/utils/firebase_analytics.dart';
@ -100,6 +101,18 @@ Future<void> startGui(List<Client> clients, SharedPreferences store) async {
await firstClient?.accountDataLoading;
ErrorWidget.builder = (details) => FluffyChatErrorWidget(details);
// #Pangea
// errors seems to happen a lot when users switch better production / staging
// while testing by accident. If the account is a production account but server is
// staging or vice versa, logout.
final isStagingUser = firstClient?.userID?.domain?.contains("staging");
final isStagingServer = Environment.isStaging;
if (isStagingServer != isStagingUser) {
await firstClient?.logout();
}
// Pangea#
runApp(FluffyChatApp(clients: clients, pincode: pin, store: store));
}