@@ -41,26 +41,40 @@ class CognitoAuthenticationService extends AuthService {
41
41
await Amplify .addPlugin (AmplifyAuthCognito ());
42
42
await Amplify .configure (config);
43
43
44
- _secureStorage = const FlutterSecureStorage ();
44
+ if (! kIsWeb)
45
+ {
46
+ _secureStorage = const FlutterSecureStorage ();
47
+ }
45
48
46
49
}
47
50
48
51
@override
49
52
Future <void > updateStoredPassword (String password) async
50
53
{
51
- await _secureStorage.write (key: 'COGNITO_PASSWORD' , value: password);
54
+ if (! kIsWeb)
55
+ {
56
+ await _secureStorage.write (key: 'COGNITO_PASSWORD' , value: password);
57
+ }
52
58
}
53
59
54
60
@override
55
61
Future <void > updateStoredEmail (String email) async
56
62
{
57
- await _secureStorage.write (key: 'COGNITO_EMAIL' , value: email);
63
+ if (! kIsWeb)
64
+ {
65
+ await _secureStorage.write (key: 'COGNITO_EMAIL' , value: email);
66
+ }
58
67
}
59
68
60
69
61
70
@override
62
71
Future <CognitoSignInResult > signInUsingStoreCredentials () async
63
72
{
73
+ if (kIsWeb)
74
+ {
75
+ return CognitoSignInResult (exception: Exception ('Not supported on web' ));
76
+ }
77
+
64
78
String ? email = await _secureStorage.read (key: 'COGNITO_EMAIL' );
65
79
String ? password = await _secureStorage.read (key: 'COGNITO_PASSWORD' );
66
80
@@ -91,8 +105,11 @@ class CognitoAuthenticationService extends AuthService {
91
105
attributes = await Amplify .Auth .fetchUserAttributes ();
92
106
}
93
107
94
- await _secureStorage.write (key: 'COGNITO_EMAIL' , value: email);
95
- await _secureStorage.write (key: 'COGNITO_PASSWORD' , value: password);
108
+ if (! kIsWeb)
109
+ {
110
+ await _secureStorage.write (key: 'COGNITO_EMAIL' , value: email);
111
+ await _secureStorage.write (key: 'COGNITO_PASSWORD' , value: password);
112
+ }
96
113
97
114
return CognitoSignInResult (data: SignInResultExtended (
98
115
signInResult: result,
@@ -159,8 +176,11 @@ class CognitoAuthenticationService extends AuthService {
159
176
{
160
177
await Amplify .Auth .signOut ();
161
178
162
- await _secureStorage.delete (key: 'COGNITO_EMAIL' );
163
- await _secureStorage.delete (key: 'COGNITO_PASSWORD' );
179
+ if (! kIsWeb)
180
+ {
181
+ await _secureStorage.delete (key: 'COGNITO_EMAIL' );
182
+ await _secureStorage.delete (key: 'COGNITO_PASSWORD' );
183
+ }
164
184
}
165
185
166
186
@override
0 commit comments