fix logout

This commit is contained in:
2026-09-06 04:31:16 +07:00
parent 47c8688884
commit 286b207f27
6 changed files with 165 additions and 98 deletions

View File

@@ -49,8 +49,31 @@ class _RootScreenState extends State<RootScreen> {
}
Future<void> _logout() async {
await Session.clear();
setState(() => _check = Session.load());
// try {
// String base = await Session.readBase();
// String? db = await Session.readDb();
// String? pass = await Session.readPass();
// String? user = await Session.readUser();
//
// int uid = await Session.readUid() ?? 0;
//
// final c = OdooClient(
// baseUrl: base, db: db!, username: user!,
// password: pass!,
// );
//
// c.logout(uid, db, pass);
// } catch(e) {
// // leave it empty
// }
await Session.clear();
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (_) => const RootScreen()),
(route) => false,
);
}
@override
@@ -177,7 +200,10 @@ class _LoginScreenState extends State<LoginScreen> {
baseUrl: base, db: _db.text.trim(), username: _user.text.trim(),
password: _pass.text,
);
await c.authenticate(); // hit; lempar bila gagal
int _uid = await c.authenticate(); // hit; lempar bila gagal
if (_uid > 0) {
await Session.saveUid(_uid);
}
await Session.save(base, _db.text.trim(), _user.text.trim(), _pass.text);
if (!mounted) return;
widget.onSuccess(base: base, db: _db.text.trim(), user: _user.text.trim(), pass: _pass.text);