Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -265,4 +265,14 @@ public void getRolesByUserId(@NonNull String userId, @NonNull AuthResponsePigeon
Log.e(getClass().getSimpleName(), "Getting user role failed!" + Arrays.toString(e.getStackTrace()));
}
}

@Override
public void getPasswordLength(@NonNull AuthResponsePigeon.Result<String> result) {
try {
String passwordLength = this.globalParamRepository.getCachedStringPasswordLength();
result.success(passwordLength);
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "Getting password Length failed!" + Arrays.toString(e.getStackTrace()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ public void getDocumentCategories(@NonNull String categoryCode, @NonNull String
result.success(documentCategory);
}

@Override
public void getDocumentSize(@NonNull DocumentCategoryPigeon.Result<String> result) {
String documentSize = "";
try {
documentSize = this.globalParamRepository.getCachedStringDocumentSize();
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "Fetch document size: " + Arrays.toString(e.getStackTrace()));
}
result.success(documentSize);
}

public String evaluateMvelScript(String scriptName, Map<String, Object> dataContext) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,6 @@ public class RegistrationConstants {
public static final String JOB_TRIGGER_POINT_USER = "User";
public static final String GPS_DEVICE_ENABLE_FLAG = "mosip.registration.gps_device_enable_flag";
public static final String DIST_FRM_MACHINE_TO_CENTER = "mosip.registration.distance.from.machine.to.center";

public static String PWORD_LENGTH = "mosip.registration.username_pwd_length";
public static String DOC_SIZE = "mosip.registration.document_size";
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ public String getCachedStringMachineToCenterDistance() {
return globalParamMap.get(RegistrationConstants.DIST_FRM_MACHINE_TO_CENTER);
}

public String getCachedStringPasswordLength() {
return globalParamMap.get(RegistrationConstants.PWORD_LENGTH);
}

public String getCachedStringDocumentSize() {
return globalParamMap.get(RegistrationConstants.DOC_SIZE);
}

/**
* Refresh configuration cache by merging global params with local preferences
*/
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": "إعدادات المهمة المجدولة",
"doc_size_existed": "حجم الملف يتجاوز الحد {size}"
}
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",
"doc_size_existed": "File size exceeds limit {size}"
}
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",
"doc_size_existed": "La taille du fichier dépasse la limite de {size}"
}
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": "अनुसूचित कार्य सेटिंग्स",
"doc_size_existed": "फ़ाइल का आकार सीमा {size} से अधिक है"
}
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": "ನಿಗದಿತ ಉದ್ಯೋಗ ಸೆಟ್ಟಿಂಗ್‌ಗಳು",
"doc_size_existed": "ಫೈಲ್ ಗಾತ್ರ ಮಿತಿ {size} ಮೀರಿದೆ"
}
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": "திட்டமிடப்பட்ட வேலை அமைப்புகள்",
"doc_size_existed": "கோப்பின் அளவு {size} வரம்பை மீறுகிறது"
}
13 changes: 13 additions & 0 deletions lib/platform_android/auth_service_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ class AuthServiceImpl implements AuthService {
return rolesList;
}

@override
Future<String> getPasswordLength() async {
late String passwordLength;
try {
passwordLength = await AuthResponseApi().getPasswordLength();
} on PlatformException {
debugPrint('getPasswordLength call failed!');
} catch (e) {
debugPrint(e.toString());
}
return passwordLength;
}

}

AuthService getAuthServiceImpl() => AuthServiceImpl();
13 changes: 13 additions & 0 deletions lib/platform_android/document_category_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,18 @@ class DocumentCategoryImpl implements DocumentCategory {
return documentValuesList;
}

@override
Future<String> getDocumentSize() async{
String documentSize = '';
try {
documentSize = await DocumentCategoryApi().getDocumentSize();
} on PlatformException {
debugPrint('DynamicServiceResponseApi call failed!');
} catch (e) {
debugPrint('Document Size not fetched! ${e.toString()}');
}
return documentSize;
}

}
DocumentCategory getDocumentCategoryImpl() => DocumentCategoryImpl();
2 changes: 2 additions & 0 deletions lib/platform_spi/auth_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ abstract class AuthService {

Future<List<String?>> getRolesByUserId(String userId);

Future<String> getPasswordLength();

factory AuthService() => getAuthServiceImpl();
}
2 changes: 2 additions & 0 deletions lib/platform_spi/document_category_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ import 'package:registration_client/platform_android/document_category_impl.dart
abstract class DocumentCategory {
Future<List<String?>> getDocumentCategories(String categoryCode,String langCode);

Future<String> getDocumentSize();

factory DocumentCategory() => getDocumentCategoryImpl();
}
8 changes: 8 additions & 0 deletions lib/provider/auth_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class AuthProvider with ChangeNotifier {
String _forgotPasswordUrl = "";
String _refreshedLoginTime = "";
String _idleTime = "";
String _passwordLength = "";

bool get isLoggedIn => _isLoggedIn;
bool get isSyncing => _isSyncing;
Expand All @@ -57,6 +58,7 @@ class AuthProvider with ChangeNotifier {
String get forgotPasswordUrl => _forgotPasswordUrl;
String get refreshedLoginTime => _refreshedLoginTime;
String get idleTime => _idleTime;
String get passwordLength => _passwordLength;

setIsLoggedIn(bool value) {
_isLoggedIn = value;
Expand Down Expand Up @@ -242,4 +244,10 @@ class AuthProvider with ChangeNotifier {
Future<List<String?>> getUserRole(String userId) async {
return await auth.getRolesByUserId(userId);
}

getPasswordLength() async {
String passwordLength = await auth.getPasswordLength();
_passwordLength = passwordLength;
notifyListeners();
}
}
5 changes: 3 additions & 2 deletions lib/ui/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class _LoginPageState extends State<LoginPage> with WidgetsBindingObserver {
_initializeAppData() async {
await globalProvider.setMachineDetails();
await globalProvider.initializeLanguageDataList(false);
await authProvider.getPasswordLength();
await globalProvider.initializeLocationHierarchyMap();
await globalProvider.setGitHeadAttributes();
await globalProvider.getAudit("REG-LOAD-001", "REG-MOD-101");
Expand Down Expand Up @@ -277,7 +278,7 @@ class _LoginPageState extends State<LoginPage> with WidgetsBindingObserver {
_showInSnackBar(appLocalizations.password_required);
return;
}
if (password.length > 50) {
if (password.length > (int.tryParse(authProvider.passwordLength) ?? 50)) {
_showInSnackBar(appLocalizations.password_exceed);
return;
}
Expand Down Expand Up @@ -513,7 +514,7 @@ class _LoginPageState extends State<LoginPage> with WidgetsBindingObserver {
context.watch<AuthProvider>().isValidUser &&
!context.watch<AuthProvider>().isNetworkPresent
? PasswordComponent(
isDisabled: password.isEmpty || password.length > 50,
isDisabled: password.isEmpty || password.length > (int.tryParse(context.watch<AuthProvider>().passwordLength) ?? 50),
onTapLogin: () async {
await _getLoginAction();
await globalProvider.getThresholdValues();
Expand Down
41 changes: 33 additions & 8 deletions lib/ui/process_ui/widgets/document_upload_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@ class _DocumentUploadControlState extends State<DocumentUploadControl> {
return "${(bytes / (1024 * 1024)).toStringAsFixed(2)} MB";
}

int maxFileSize = 2 * 1024 * 1024; // Default 2MB

_fetchMaxFileSize() async {
try {
String sizeStr = await registrationTaskProvider.documentCategory.getDocumentSize();
if (sizeStr.isNotEmpty) {
int? size = int.tryParse(sizeStr);
if (size != null && size > 0) {
setState(() {
maxFileSize = size;
});
}
}
} catch (e) {
debugPrint("Failed to fetch document size limit: $e");
}
}

_showError(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message), backgroundColor: Colors.red));
}


FixedExtentScrollController scrollController = FixedExtentScrollController();
@override
Expand All @@ -62,6 +85,7 @@ class _DocumentUploadControlState extends State<DocumentUploadControl> {
getScannedDocuments(widget.field);
myGetDocumentCategoryFuture =
_getDocumentType(widget.field.subType!, "eng");
_fetchMaxFileSize();
}

if (context
Expand Down Expand Up @@ -164,14 +188,15 @@ class _DocumentUploadControlState extends State<DocumentUploadControl> {
}

Future<void> addDocument(var item, Field e, String referenceNumber) async {
// final bytes = await getImageBytes(item);

debugPrint(
"The selected value for dropdown for ${e.id!} is ${documentController.text}");
// Uint8List myBytes = Uint8List.fromList(bytes);
// context
// .read<RegistrationTaskProvider>()
// .addDocument(e.id!, selected!, "reference", myBytes);
if (item == null) return;
if (item is Uint8List) {
if (item.lengthInBytes > maxFileSize) {
final msg = AppLocalizations.of(context)!
.doc_size_existed(getReadableFileSize(item.lengthInBytes));
_showError(msg);
return;
}
}
_getAddDocumentProvider(e, item, referenceNumber);
}

Expand Down
2 changes: 2 additions & 0 deletions pigeon/auth_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ abstract class AuthResponseApi {
String getAutoLogoutPopupTimeout();
@async
List<String> getRolesByUserId(String userId);
@async
String getPasswordLength();
}
3 changes: 3 additions & 0 deletions pigeon/document_category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ import 'package:pigeon/pigeon.dart';
abstract class DocumentCategoryApi {
@async
List<String> getDocumentCategories(String categoryCode,String langCode);

@async
String getDocumentSize();
}