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

View file

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

View file

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

View file

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