download option in invoide

This commit is contained in:
Abhishek Mali
2025-12-19 10:48:19 +05:30
parent d606156a6d
commit e85ac4bf8c
5 changed files with 124 additions and 28 deletions

View File

@@ -125,23 +125,27 @@ class AuthProvider extends ChangeNotifier {
return res['success'] == true;
}
// --------------------- REFRESH TOKEN --------------------------
Future<bool> tryRefreshToken(BuildContext context) async {
Future<void> forceLogout(BuildContext context) async {
debugPrint('🚪🚪🚪 [AUTH] Force logout triggered');
final prefs = await SharedPreferences.getInstance();
final oldToken = prefs.getString('token');
if (oldToken == null) return false;
await prefs.remove('token');
await prefs.remove('user');
await prefs.remove('saved_login_id');
await prefs.remove('saved_password');
_service ??= AuthService(context);
_token = null;
_user = null;
final res = await _service!.refreshToken(oldToken);
notifyListeners();
if (res['success'] == true && res['token'] != null) {
await prefs.setString('token', res['token']);
_token = res['token'];
notifyListeners();
return true;
}
return false;
// Redirect to login & clear navigation stack
Navigator.of(context).pushNamedAndRemoveUntil(
'/login',
(route) => false,
);
}
}