@@ -42,7 +42,7 @@ class _LoginScreenState extends State<LoginScreen> {
42
42
43
43
final userInfo = UserInfo (
44
44
role: 'admin' ,
45
- id: googleUser.email,
45
+ id: createValidId ( googleUser.email) ,
46
46
name: googleUser.displayName ?? '' ,
47
47
image: googleUser.photoUrl,
48
48
);
@@ -56,7 +56,7 @@ class _LoginScreenState extends State<LoginScreen> {
56
56
57
57
final userInfo = UserInfo (
58
58
role: 'admin' ,
59
- id: email. replaceAll ( '@' , '_' ). replaceAll ( '.' , '_' ),
59
+ id: createValidId (email ),
60
60
name: email,
61
61
);
62
62
@@ -82,9 +82,20 @@ class _LoginScreenState extends State<LoginScreen> {
82
82
83
83
// Register StreamVideo client with the user.
84
84
final authController = locator.get <UserAuthController >();
85
- await authController.login (user, environment);
86
85
87
- if (mounted) hideLoadingIndicator (context);
86
+ try {
87
+ await authController.login (user, environment);
88
+ } catch (e, _) {
89
+ if (mounted) {
90
+ hideLoadingIndicator (context);
91
+ ScaffoldMessenger .of (context).showSnackBar (
92
+ SnackBar (
93
+ duration: const Duration (seconds: 20 ),
94
+ content: Text ('Error: $e ' ),
95
+ ),
96
+ );
97
+ }
98
+ }
88
99
}
89
100
90
101
@override
@@ -268,3 +279,7 @@ String randomId({int size = 21}) {
268
279
}
269
280
return id;
270
281
}
282
+
283
+ String createValidId (String id) {
284
+ return id.replaceAll (RegExp (r'[^\w]' ), '_' );
285
+ }
0 commit comments