Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void onResponse(Call call, Response response) {
if (error == null) {
errorCode = "REG_TRY_AGAIN";
} else if (error.getMessage().equals("Invalid Request")) {
errorCode = "REG_INVALID_REQUEST";
errorCode = "REG_AUTH_SERVER_DOWN";
} else if (error.getMessage().equals("Machine not found")) {
errorCode = "REG_MACHINE_NOT_FOUND";
} else {
Expand Down
3 changes: 2 additions & 1 deletion assets/l10n/app_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,6 @@
"enter_additional_info_req_id": "أدخل معرف طلب المعلومات الإضافية",
"additional_info_req_id": "معرف طلب المعلومات الإضافية",
"no_access_to_this_page": "ليست لديك صلاحية الوصول إلى هذه الصفحة",
"scheduled_job_settings": "إعدادات المهمة المجدولة"
"scheduled_job_settings": "إعدادات المهمة المجدولة",
"server_unreachable": "خادم المصادقة غير متاح. يرجى المحاولة مرة أخرى لاحقًا"
}
3 changes: 2 additions & 1 deletion assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,6 @@
"enter_additional_info_req_id": "Enter Additional Info Request ID",
"additional_info_req_id": "Additional Info Request ID",
"scheduled_job_settings": "Scheduled Job Settings",
"no_access_to_this_page": "You don't have access to this page"
"no_access_to_this_page": "You don't have access to this page",
"server_unreachable": "Authentication server unreachable. Please try again later"
}
3 changes: 2 additions & 1 deletion assets/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,6 @@
"enter_additional_info_req_id": "Entrez l'identifiant de la demande d'information supplémentaire",
"additional_info_req_id": "Identifiant de la demande d'information supplémentaire",
"no_access_to_this_page": "Vous n'avez pas accès à cette page",
"scheduled_job_settings": "Paramètres des tâches planifiées"
"scheduled_job_settings": "Paramètres des tâches planifiées",
"server_unreachable": "Le serveur d’authentification est inaccessible. Veuillez réessayer plus tard"
}
3 changes: 2 additions & 1 deletion assets/l10n/app_hi.arb
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,6 @@
"enter_additional_info_req_id": "अतिरिक्त जानकारी अनुरोध आईडी दर्ज करें",
"additional_info_req_id": "अतिरिक्त जानकारी अनुरोध आईडी",
"no_access_to_this_page": "आपको इस पृष्ठ तक पहुँच नहीं है",
"scheduled_job_settings": "अनुसूचित कार्य सेटिंग्स"
"scheduled_job_settings": "अनुसूचित कार्य सेटिंग्स",
"server_unreachable": "प्रमाणीकरण सर्वर उपलब्ध नहीं है। कृपया बाद में पुनः प्रयास करें"
}
3 changes: 2 additions & 1 deletion assets/l10n/app_kn.arb
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,6 @@
"enter_additional_info_req_id": "ಹೆಚ್ಚುವರಿ ಮಾಹಿತಿ ವಿನಂತಿ ಐಡಿ ನಮೂದಿಸಿ",
"additional_info_req_id": "ಹೆಚ್ಚುವರಿ ಮಾಹಿತಿ ವಿನಂತಿ ಐಡಿ",
"no_access_to_this_page": "ನಿಮಗೆ ಈ ಪುಟಕ್ಕೆ ಪ್ರವೇಶವಿಲ್ಲ",
"scheduled_job_settings": "ನಿಗದಿತ ಉದ್ಯೋಗ ಸೆಟ್ಟಿಂಗ್‌ಗಳು"
"scheduled_job_settings": "ನಿಗದಿತ ಉದ್ಯೋಗ ಸೆಟ್ಟಿಂಗ್‌ಗಳು",
"server_unreachable": "ಪ್ರಮಾಣೀಕರಣ ಸರ್ವರ್‌ ಅನ್ನು ಸಂಪರ್ಕಿಸಲು ಸಾಧ್ಯವಾಗುವುದಿಲ್ಲ. ದಯವಿಟ್ಟು ನಂತರ ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ"
}
3 changes: 2 additions & 1 deletion assets/l10n/app_ta.arb
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,6 @@
"enter_additional_info_req_id": "கூடுதல் தகவல் கோரிக்கை ஐடியை உள்ளிடவும்",
"additional_info_req_id": "கூடுதல் தகவல் கோரிக்கை ஐடி",
"no_access_to_this_page": "இந்தப் பக்கத்தை அணுக உங்களுக்கு அனுமதி இல்லை",
"scheduled_job_settings": "திட்டமிடப்பட்ட வேலை அமைப்புகள்"
"scheduled_job_settings": "திட்டமிடப்பட்ட வேலை அமைப்புகள்",
"server_unreachable": "அங்கீகார சேவையகத்தை அணுக முடியவில்லை. தயவுசெய்து பின்னர் மீண்டும் முயற்சிக்கவும்"
}
6 changes: 6 additions & 0 deletions lib/ui/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ class _LoginPageState extends State<LoginPage> with WidgetsBindingObserver {
if (errorMsg == "") {
return;
}

if (errorMsg == "REG_AUTH_SERVER_DOWN" || errorMsg == "KER-SYN-AUTH-001" || errorMsg == "Invalid Request") {
_showInSnackBar(appLocalizations.server_unreachable);
return;
}
Comment on lines +357 to +360
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Potential redundancy and fragile string comparison in error handling.

This code checks for three conditions: REG_AUTH_SERVER_DOWN, KER-SYN-AUTH-001, and "Invalid Request". Based on the changes in AuthenticationApi.java, the server message "Invalid Request" is now mapped to REG_AUTH_SERVER_DOWN before reaching the UI. This raises two concerns:

  1. Redundancy: Checking for both the error code (REG_AUTH_SERVER_DOWN) and the raw message ("Invalid Request") suggests either defensive programming or confusion about the error flow. If they're both needed, please clarify the different scenarios where each condition is true.

  2. Fragile string comparison: Directly comparing errorMsg == "Invalid Request" is fragile—if the server message changes or gets localized, this will silently fail. Error codes should be used consistently for error handling.

Recommendation: Consider adding REG_AUTH_SERVER_DOWN and KER-SYN-AUTH-001 to the errors mapping in the ARB files (line 308) for consistency, rather than handling them as special cases here. This would align with how other error codes are handled.

// Instead of special-case handling, consider:
// 1. Add to errors mapping in ARB files:
// "errors": "{messages, select, ..., REG_AUTH_SERVER_DOWN{Authentication server unreachable. Please try again later}, KER-SYN-AUTH-001{Authentication server unreachable. Please try again later}, ...}"
// 
// 2. Remove the special case and let the existing logic handle it:
// String snackbarText = appLocalizations.errors(errorMsg);
// if (snackbarText == "Some error occurred!") {
//   snackbarText = errorMsg;
// }
// _showInSnackBar(snackbarText);
🤖 Prompt for AI Agents
In lib/ui/login_page.dart around lines 357 to 360, the code special-cases
errorMsg values ("REG_AUTH_SERVER_DOWN", "KER-SYN-AUTH-001", and the raw
"Invalid Request") which is redundant and fragile; update the ARB error mapping
(around line 308) to include REG_AUTH_SERVER_DOWN and KER-SYN-AUTH-001 with the
desired user-facing text, remove the special-case if-block here, and let
appLocalizations.errors(errorMsg) drive the snackbar text; if you must keep both
checks, add a brief comment explaining the distinct server/client scenarios and
replace the raw-string comparison with a check against a centralized constant or
enum to avoid fragile literal matching.


String snackbarText = "";
snackbarText = appLocalizations.errors(errorMsg);
if (snackbarText == "Some error occurred!") {
Expand Down