Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -166,8 +166,8 @@ PacketAuthenticationApi getPacketAuthenticationApi(SyncRestService syncRestServi

@Provides
@Singleton
DemographicsDetailsApi getDemographicsDetailsApi(RegistrationService registrationService, AuditManagerService auditManagerService) {
return new DemographicsDetailsApi(registrationService, auditManagerService);
DemographicsDetailsApi getDemographicsDetailsApi(RegistrationService registrationService, AuditManagerService auditManagerService, GlobalParamRepository globalParamRepository) {
return new DemographicsDetailsApi(registrationService, auditManagerService, globalParamRepository);
}

@Provides
Expand Down
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 @@ -18,6 +18,7 @@
import javax.inject.Singleton;

import io.mosip.registration.clientmanager.dto.registration.RegistrationDto;
import io.mosip.registration.clientmanager.repository.GlobalParamRepository;
import io.mosip.registration.clientmanager.spi.AuditManagerService;
import io.mosip.registration.clientmanager.spi.RegistrationService;
import io.mosip.registration.keymanager.util.CryptoUtil;
Expand All @@ -30,11 +31,13 @@ public class DemographicsDetailsApi implements DemographicsDataPigeon.Demographi
AuditManagerService auditManagerService;
private static final String GET_FIELD_FAILED_MESSAGE = "Get field failed!";

GlobalParamRepository globalParamRepository;

@Inject
public DemographicsDetailsApi(RegistrationService registrationService, AuditManagerService auditManagerService) {
public DemographicsDetailsApi(RegistrationService registrationService, AuditManagerService auditManagerService, GlobalParamRepository globalParamRepository) {
this.registrationService = registrationService;
this.auditManagerService = auditManagerService;

this.globalParamRepository = globalParamRepository;
}


Expand Down Expand Up @@ -195,4 +198,18 @@ public void addSelectedCode(@NonNull String fieldId, @NonNull String code, @NonN
Log.e(getClass().getSimpleName(), "Add selected data field failed!" + Arrays.toString(e.getStackTrace()));
}
}

@Override
public void getDOBMaxAge(@NonNull DemographicsDataPigeon.Result<String> result) {
String dobMaxAge = "";
try {
String value = this.globalParamRepository.getCachedStringDOBAgeLimit();
if (value != null) {
dobMaxAge = value;
}
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "Get DOB max age failed!" + Arrays.toString(e.getStackTrace()));
}
result.success(dobMaxAge);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
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,7 @@ 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 final String PWORD_LENGTH = "mosip.registration.username_pwd_length";
public static final String DOC_SIZE = "mosip.registration.document_size";
public static final String MAX_AGE = "mosip.registration.max_age";
Comment thread
This conversation was marked as resolved.
Resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ 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);
}

public String getCachedStringDOBAgeLimit() {
return globalParamMap.get(RegistrationConstants.MAX_AGE);
}

/**
* Refresh configuration cache by merging global params with local preferences
*/
Expand Down
18 changes: 17 additions & 1 deletion assets/l10n/app_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,21 @@
"enter_additional_info_req_id": "أدخل معرف طلب المعلومات الإضافية",
"additional_info_req_id": "معرف طلب المعلومات الإضافية",
"no_access_to_this_page": "ليست لديك صلاحية الوصول إلى هذه الصفحة",
"scheduled_job_settings": "إعدادات المهمة المجدولة"
"scheduled_job_settings": "إعدادات المهمة المجدولة",
"doc_size_exceeded": "حجم الملف يتجاوز الحد {size}",
"@doc_size_exceeded": {
"placeholders": {
"size": {
"type": "String"
}
}
},
"age_should_not_be_greater": "يجب ألا يزيد العمر عن {age} سنة",
"@age_should_not_be_greater": {
"placeholders": {
"age": {
"type": "int"
}
}
}
}
18 changes: 17 additions & 1 deletion assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,21 @@
"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_exceeded": "File size exceeds limit {size}",
"@doc_size_exceeded": {
"placeholders": {
"size": {
"type": "String"
}
}
},
"age_should_not_be_greater": "Age should not be greater than {age} years",
"@age_should_not_be_greater": {
"placeholders": {
"age": {
"type": "int"
}
}
}
}
18 changes: 17 additions & 1 deletion assets/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,21 @@
"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_exceeded": "La taille du fichier dépasse la limite de {size}",
"@doc_size_exceeded": {
"placeholders": {
"size": {
"type": "String"
}
}
},
"age_should_not_be_greater": "L'âge ne doit pas dépasser {age} ans.",
"@age_should_not_be_greater": {
"placeholders": {
"age": {
"type": "int"
}
}
}
}
18 changes: 17 additions & 1 deletion assets/l10n/app_hi.arb
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,21 @@
"enter_additional_info_req_id": "अतिरिक्त जानकारी अनुरोध आईडी दर्ज करें",
"additional_info_req_id": "अतिरिक्त जानकारी अनुरोध आईडी",
"no_access_to_this_page": "आपको इस पृष्ठ तक पहुँच नहीं है",
"scheduled_job_settings": "अनुसूचित कार्य सेटिंग्स"
"scheduled_job_settings": "अनुसूचित कार्य सेटिंग्स",
"doc_size_exceeded": "फ़ाइल का आकार सीमा {size} से अधिक है",
"@doc_size_exceeded": {
"placeholders": {
"size": {
"type": "String"
}
}
},
"age_should_not_be_greater": "उम्र {age} वर्ष से अधिक नहीं होनी चाहिए।",
"@age_should_not_be_greater": {
"placeholders": {
"age": {
"type": "int"
}
}
}
}
18 changes: 17 additions & 1 deletion assets/l10n/app_kn.arb
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,21 @@
"enter_additional_info_req_id": "ಹೆಚ್ಚುವರಿ ಮಾಹಿತಿ ವಿನಂತಿ ಐಡಿ ನಮೂದಿಸಿ",
"additional_info_req_id": "ಹೆಚ್ಚುವರಿ ಮಾಹಿತಿ ವಿನಂತಿ ಐಡಿ",
"no_access_to_this_page": "ನಿಮಗೆ ಈ ಪುಟಕ್ಕೆ ಪ್ರವೇಶವಿಲ್ಲ",
"scheduled_job_settings": "ನಿಗದಿತ ಉದ್ಯೋಗ ಸೆಟ್ಟಿಂಗ್‌ಗಳು"
"scheduled_job_settings": "ನಿಗದಿತ ಉದ್ಯೋಗ ಸೆಟ್ಟಿಂಗ್‌ಗಳು",
"doc_size_exceeded": "ಫೈಲ್ ಗಾತ್ರ ಮಿತಿ {size} ಮೀರಿದೆ",
"@doc_size_exceeded": {
"placeholders": {
"size": {
"type": "String"
}
}
},
"age_should_not_be_greater": "ವಯಸ್ಸು {age} ವರ್ಷಗಳಿಗಿಂತ ಹೆಚ್ಚಿರಬಾರದು",
"@age_should_not_be_greater": {
"placeholders": {
"age": {
"type": "int"
}
}
}
}
18 changes: 17 additions & 1 deletion assets/l10n/app_ta.arb
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,21 @@
"enter_additional_info_req_id": "கூடுதல் தகவல் கோரிக்கை ஐடியை உள்ளிடவும்",
"additional_info_req_id": "கூடுதல் தகவல் கோரிக்கை ஐடி",
"no_access_to_this_page": "இந்தப் பக்கத்தை அணுக உங்களுக்கு அனுமதி இல்லை",
"scheduled_job_settings": "திட்டமிடப்பட்ட வேலை அமைப்புகள்"
"scheduled_job_settings": "திட்டமிடப்பட்ட வேலை அமைப்புகள்",
"doc_size_exceeded": "கோப்பின் அளவு {size} வரம்பை மீறுகிறது",
"@doc_size_exceeded": {
"placeholders": {
"size": {
"type": "String"
}
}
},
"age_should_not_be_greater": "வயது {age} ஆண்டுகளுக்கு அதிகமாக இருக்கக்கூடாது",
"@age_should_not_be_greater": {
"placeholders": {
"age": {
"type": "int"
}
}
}
}
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/demographic_service_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ class DemographicServiceImpl implements DemographicService {
debugPrint('Selected Code not added ${e.toString()}');
}
}

@override
Future<String> getDOBMaxAge() async {
String maxAge = "";
try {
maxAge = await DemographicsApi().getDOBMaxAge();
} on PlatformException {
debugPrint('DemographicsApi call failed');
} catch (e) {
debugPrint('Max Age not fetched ${e.toString()}');
}
return maxAge;
}
}

DemographicService getDemographicServiceImpl() => DemographicServiceImpl();
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/demographic_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ abstract class DemographicService {

Future<void> addSelectedCode(String fieldId,String code);

Future<String> getDOBMaxAge();

factory DemographicService() => getDemographicServiceImpl();
}
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
Loading