Skip to content

Commit

Permalink
invalid api key wip
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 committed Jan 2, 2025
1 parent 464740e commit 17b7fd2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/model/store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,10 @@ class UpdateMachine {
BackoffMachine? backoffMachine;
while (true) {
try {
throw ZulipApiException(
routeName: '/register', code: 'INVALID_API_KEY', httpStatus: 400,
data: {}, message: '');
// ignore: dead_code
return await registerQueue(connection);
} catch (e, s) {
assert(debugLog('Error fetching initial snapshot: $e'));
Expand All @@ -915,11 +919,11 @@ class UpdateMachine {
// TODO(#890): tell user if initial-fetch errors persist, or look non-transient
switch (e) {
case ZulipApiException(code: 'INVALID_API_KEY'):
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
reportErrorToUserModally(
zulipLocalizations.errorCouldNotConnectTitle,
details: zulipLocalizations.errorInvalidApiKeyMessage(
connection.realmUrl.toString()));
// final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
// reportErrorToUserModally(
// zulipLocalizations.errorCouldNotConnectTitle,
// details: zulipLocalizations.errorInvalidApiKeyMessage(
// connection.realmUrl.toString()));
rethrow;
}
await (backoffMachine ??= BackoffMachine()).wait();
Expand Down
9 changes: 9 additions & 0 deletions lib/widgets/store.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';

import '../api/exception.dart';
import '../model/binding.dart';
import '../model/store.dart';
import 'actions.dart';
import 'app.dart';
import 'page.dart';

/// Provides access to the app's data.
Expand Down Expand Up @@ -259,6 +263,11 @@ class _PerAccountStoreWidgetState extends State<PerAccountStoreWidget> {
// unless the user retries manually.
// TODO(#737): Reset the navigator stack and bring the user back
// to the choose-account page.
if (!mounted) return;
unawaited(
Navigator.push(context, MaterialWidgetRoute(page: const ChooseAccountPage())));
await logOutAccount(context, widget.accountId);

return;
default:
rethrow;
Expand Down

0 comments on commit 17b7fd2

Please sign in to comment.