Skip to content

Commit

Permalink
Merge branch 'develop' into fix/Controller-Dispose-method
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinho13 authored Nov 12, 2024
2 parents df701d8 + e30a31c commit a816818
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 42 deletions.
2 changes: 1 addition & 1 deletion packages/uni_app/app_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.10.0-beta.35+338
1.10.0-beta.36+339
11 changes: 0 additions & 11 deletions packages/uni_app/lib/model/entities/login_exceptions.dart

This file was deleted.

1 change: 1 addition & 0 deletions packages/uni_app/lib/session/exception.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
enum AuthenticationExceptionType {
internetError,
wrongCredentials,
expiredCredentials,
other,
Expand Down
12 changes: 11 additions & 1 deletion packages/uni_app/lib/session/flows/credentials/request.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'package:http/http.dart' as http;
import 'package:uni/controller/fetchers/faculties_fetcher.dart';
import 'package:uni/session/exception.dart';
Expand Down Expand Up @@ -35,11 +36,20 @@ class CredentialsSessionRequest extends SessionRequest {
'Failed to authenticate user',
AuthenticationExceptionType.expiredCredentials,
);
} else {
} else if (failureReason == LoginFailureReason.internetError) {
throw const AuthenticationException(
'Failed to authenticate user',
AuthenticationExceptionType.internetError,
);
} else if (failureReason == LoginFailureReason.wrongCredentials) {
throw const AuthenticationException(
'Failed to authenticate user',
AuthenticationExceptionType.wrongCredentials,
);
} else {
throw const AuthenticationException(
'Failed to authenticate user',
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class LoginResponse extends SigarraResponse {

enum LoginFailureReason {
serverError,
internetError,
wrongCredentials,
expiredCredentials,
blockedAccount,
Expand Down
71 changes: 43 additions & 28 deletions packages/uni_app/lib/view/login/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:uni/app_links/uni_app_links.dart';
import 'package:uni/controller/networking/url_launcher.dart';
import 'package:uni/generated/l10n.dart';
import 'package:uni/model/entities/login_exceptions.dart';
import 'package:uni/model/providers/startup/session_provider.dart';
import 'package:uni/model/providers/state_providers.dart';
import 'package:uni/session/exception.dart';
import 'package:uni/session/flows/credentials/initiator.dart';
import 'package:uni/session/flows/federated/initiator.dart';
import 'package:uni/utils/constants.dart';
Expand Down Expand Up @@ -99,36 +99,51 @@ class LoginPageViewState extends State<LoginPageView>
_loggingIn = false;
});
}
} catch (err, st) {
} on AuthenticationException catch (err, st) {
setState(() {
_loggingIn = false;
});
if (err is ExpiredCredentialsException) {
_updatePasswordDialog();
} else if (err is InternetStatusException) {
if (mounted) {
unawaited(
ToastMessage.warning(
context,
S.of(context).internet_status_exception,
),
);
}
} else if (err is WrongCredentialsException) {
if (mounted) {
unawaited(
ToastMessage.error(
context,
S.of(context).wrong_credentials_exception,
),
);
}
} else {
Logger().e(err, stackTrace: st);
unawaited(Sentry.captureException(err, stackTrace: st));
if (mounted) {
unawaited(ToastMessage.error(context, S.of(context).failed_login));
}

switch (err.type) {
case AuthenticationExceptionType.expiredCredentials:
_updatePasswordDialog();
case AuthenticationExceptionType.internetError:
if (mounted) {
unawaited(
ToastMessage.warning(
context,
S.of(context).internet_status_exception,
),
);
}
case AuthenticationExceptionType.wrongCredentials:
if (mounted) {
unawaited(
ToastMessage.error(
context,
S.of(context).wrong_credentials_exception,
),
);
}
default:
Logger().e(err, stackTrace: st);
unawaited(Sentry.captureException(err, stackTrace: st));
if (mounted) {
unawaited(
ToastMessage.error(context, S.of(context).failed_login),
);
}
}
}
// Handles other unexpected exceptions
catch (err, st) {
setState(() {
_loggingIn = false;
});
Logger().e(err, stackTrace: st);
unawaited(Sentry.captureException(err, stackTrace: st));
if (mounted) {
unawaited(ToastMessage.error(context, S.of(context).failed_login));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/uni_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish_to: "none" # We do not publish to pub.dev
# To change it manually, override the value in app_version.txt.
# The app version code is automatically also bumped by CI.
# Do not change it manually.
version: 1.10.0-beta.35+338
version: 1.10.0-beta.36+339

environment:
sdk: ">=3.4.0 <4.0.0"
Expand Down

0 comments on commit a816818

Please sign in to comment.