Handle session expiries gracefully

This commit is contained in:
Vishnu 2021-06-26 16:26:52 +05:30
parent b7f8f02370
commit 1547c5499f

View file

@ -10,6 +10,7 @@ import 'package:photos/models/key_gen_result.dart';
import 'package:photos/models/public_key.dart';
import 'package:photos/models/set_keys_request.dart';
import 'package:photos/models/set_recovery_key_request.dart';
import 'package:photos/ui/login_page.dart';
import 'package:photos/ui/ott_verification_page.dart';
import 'package:photos/ui/password_entry_page.dart';
import 'package:photos/ui/password_reentry_page.dart';
@ -226,6 +227,23 @@ class UserService {
showErrorDialog(
context, "oops", "authentication failed, please try again");
}
} on DioError catch (e) {
await dialog.hide();
_logger.severe(e);
if (e.response != null && e.response.statusCode == 404) {
showToast("session expired");
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
return LoginPage();
},
),
(route) => route.isFirst,
);
} else {
showErrorDialog(context, "incorrect code",
"authentication failed, please try again");
}
} catch (e) {
await dialog.hide();
_logger.severe(e);