fix web load

This commit is contained in:
Daniel 2024-08-15 13:57:26 -04:00
parent 596c9863ef
commit d87b497e30
4 changed files with 8 additions and 4 deletions

View file

@ -70,6 +70,7 @@ class Stillbox extends ChangeNotifier {
); );
if (response.statusCode == 200) { if (response.statusCode == 200) {
String? token = channel.updateCookie(response); String? token = channel.updateCookie(response);
print('token is $token');
storage.setKey('baseURL', uri); storage.setKey('baseURL', uri);
if (!kIsWeb && token != null) { if (!kIsWeb && token != null) {
storage.setKey('token', token); storage.setKey('token', token);
@ -98,10 +99,12 @@ class Stillbox extends ChangeNotifier {
String? storedToken = await storage.getKey('token'); String? storedToken = await storage.getKey('token');
late String? storedUri; late String? storedUri;
storedUri = await storage.getKey('baseURL'); storedUri = await storage.getKey('baseURL');
if (storedToken == null || storedUri == null) { if ((!kIsWeb && storedToken == null) || storedUri == null) {
throw (BadAuthException); throw (BadAuthException);
} }
channel.setCookie(storedToken); if (!kIsWeb) {
channel.setCookie(storedToken!);
}
baseUri = Uri.parse(storedUri); baseUri = Uri.parse(storedUri);
setUris(); setUris();
} }

View file

@ -6,7 +6,7 @@ class Storer {
return null; return null;
} }
void setKey(String key, String value) { Future<void> setKey(String key, String value) async {
return; return;
} }
} }

View file

@ -7,7 +7,7 @@ class Storer {
return window.localStorage[key]; return window.localStorage[key];
} }
void setKey(String key, String value) { Future<void> setKey(String key, String value) async {
window.localStorage[key] = value; window.localStorage[key] = value;
} }
} }

View file

@ -98,6 +98,7 @@ class _LoginState extends State<Login> {
uriController.text, uriController.text,
userController.text, userController.text,
passwordController.text); passwordController.text);
print("result is $result");
if (context.mounted && result == true) { if (context.mounted && result == true) {
Navigator.pushReplacement( Navigator.pushReplacement(
context, context,