This repository has been archived on 2024-07-21. You can view files and clone it, but cannot push or open issues or pull requests.
opencanteen/lib/loginmanager.dart

26 lines
944 B
Dart
Raw Normal View History

2022-04-04 20:22:30 +02:00
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
class LoginManager {
static Future<Map<String, String>?> getDetails() async {
// check secure storage for details
2022-04-04 20:22:30 +02:00
const storage = FlutterSecureStorage();
var user = await storage.read(key: "oc_user");
var pass = await storage.read(key: "oc_pass");
var url = await storage.read(key: "oc_url");
if (user == null || pass == null || url == null) return null;
return {"user": user, "pass": pass, "url": url};
}
static Future<void> setDetails(String user, String pass, String url) async {
const storage = FlutterSecureStorage();
await storage.write(key: "oc_user", value: user);
await storage.write(key: "oc_pass", value: pass);
await storage.write(key: "oc_url", value: url);
}
2022-04-26 18:20:42 +02:00
static Future<bool> rememberme() async {
2022-04-26 18:20:42 +02:00
const storage = FlutterSecureStorage();
return await storage.containsKey(key: "oc_pass");
}
2022-04-04 20:22:30 +02:00
}