Skip to content

Commit

Permalink
feat: password error five times in login error hanlde
Browse files Browse the repository at this point in the history
  • Loading branch information
abc873693 committed Jan 6, 2024
1 parent e6b472c commit 82d2f32
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/api/ap_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ class WebApHelper {
statusCode: ApStatusCode.userDataError,
message: 'username or password error',
);
case 5:
throw GeneralResponse(
statusCode: ApStatusCode.passwordFiveTimesError,
message: 'username or password error',
);
case 500:
throw GeneralResponse(
statusCode: ApStatusCode.schoolServerError,
Expand Down
1 change: 1 addition & 0 deletions lib/api/ap_status_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class ApStatusCode {
static const int cancel = 100;
static const int userDataError = 1401;
static const int unknownError = 1402;
static const int passwordFiveTimesError = 1405;

//Common
static const int apiExpire = 401;
Expand Down
2 changes: 2 additions & 0 deletions lib/api/parser/ap_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class WebApParser {
return 999;
} else if (match.contains('無此帳號或密碼不正確')) {
return 1;
} else if (match.contains('您先前已登入')) {
return 5;
} else if (match.contains('繁忙')) {
return 500;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ class HomePageState extends State<HomePage> {
},
onError: (GeneralResponse response) async {
String message = '';
if (response.statusCode == ApStatusCode.userDataError) {
if (response.statusCode == ApStatusCode.userDataError ||
response.statusCode == ApStatusCode.passwordFiveTimesError) {
Toast.show(ap.passwordError, context);
await Preferences.setBool(Constants.prefAutoLogin, false);
checkLogin();
Expand Down
4 changes: 4 additions & 0 deletions lib/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ class LoginPageState extends State<LoginPage> {
case ApStatusCode.userDataError:
message = ap.loginFail;
break;
case ApStatusCode.passwordFiveTimesError:
//TODO i18n
message = '您先前已登入失敗達5次!!請30分鐘後再嘗試登入!!';
break;
case ApStatusCode.cancel:
message = null;
break;
Expand Down

0 comments on commit 82d2f32

Please sign in to comment.