From 99ff10d8c3fc5de6e8f294d76484fb3c00a69bbd Mon Sep 17 00:00:00 2001 From: Sachin S P Date: Thu, 18 Jul 2024 17:14:48 +0530 Subject: [PATCH 1/5] forgot password implementation Signed-off-by: Sachin S P --- android/app/src/main/AndroidManifest.xml | 6 +++ assets/l10n/app_ar.arb | 7 ++- assets/l10n/app_en.arb | 7 ++- assets/l10n/app_fr.arb | 7 ++- assets/l10n/app_hi.arb | 7 ++- assets/l10n/app_kn.arb | 7 ++- assets/l10n/app_ta.arb | 7 ++- assets/svg/No internet connection.svg | 7 +++ lib/provider/auth_provider.dart | 8 +++ lib/ui/login_page.dart | 36 ++++++++++++- lib/ui/widgets/network_component.dart | 68 ++++++++++++++++++++++++ lib/ui/widgets/password_component.dart | 50 +++++++++++------ 12 files changed, 188 insertions(+), 29 deletions(-) create mode 100644 assets/svg/No internet connection.svg create mode 100644 lib/ui/widgets/network_component.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 48547a734..bdf192c62 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -46,4 +46,10 @@ android:name="flutterEmbedding" android:value="2" /> + + + + + + diff --git a/assets/l10n/app_ar.arb b/assets/l10n/app_ar.arb index 28538fed1..3d31d88b9 100644 --- a/assets/l10n/app_ar.arb +++ b/assets/l10n/app_ar.arb @@ -18,7 +18,7 @@ "next_button": "مقبل", "password": "شعار", "enter_password": "أدخل كلمة المرور", - "forgot_password": "نسيت كلمة المرور?", + "forgot_password": "نسيت كلمة المرور", "login_button": "تسجيل الدخول", "back_button": "ظهر", "user_validated": "تم التحقق من صحة المستخدم!", @@ -248,5 +248,8 @@ "offline": "غير متصل على الانترنت", "logout_success": "لقد تم تسجيل بنجاح!", "logout_failure": "حدث خطأ ما، يرجى المحاولة مرة أخرى بعد مرور بعض الوقت", - "go_to_home": "اذهب إلى المنزل" + "go_to_home": "اذهب إلى المنزل", + "no_internet_connection": "لا يوجد اتصال بالإنترنت!", + "connect_and_retry": "يرجى الاتصال بالإنترنت وإعادة المحاولة.", + "retry": "إعادة المحاولة" } \ No newline at end of file diff --git a/assets/l10n/app_en.arb b/assets/l10n/app_en.arb index ce0319ba2..49fb660d1 100644 --- a/assets/l10n/app_en.arb +++ b/assets/l10n/app_en.arb @@ -18,7 +18,7 @@ "next_button": "NEXT", "password": "Password", "enter_password": "Enter Password", - "forgot_password": "Forgot Password?", + "forgot_password": "FORGOT PASSWORD", "login_button": "LOGIN", "back_button": "BACK", "user_validated": "User Validated!", @@ -248,5 +248,8 @@ "offline": "Offline", "logout_success": "You have been successfully logged out!", "logout_failure": "Something went wrong, please try again after some time", - "go_to_home": "Go To Home" + "go_to_home": "Go To Home", + "no_internet_connection": "No Internet Connection!", + "connect_and_retry": "Please connect with internet and retry.", + "retry": "RETRY" } \ No newline at end of file diff --git a/assets/l10n/app_fr.arb b/assets/l10n/app_fr.arb index 41d73d1cf..de8765234 100644 --- a/assets/l10n/app_fr.arb +++ b/assets/l10n/app_fr.arb @@ -18,7 +18,7 @@ "next_button": "PROCHAINE", "password": "Mot de passe", "enter_password": "Entrez le mot de passe", - "forgot_password": "Mot de passe oublié?", + "forgot_password": "MOT DE PASSE OUBLIÉ", "login_button": "CONNECTEZ-VOUS", "back_button": "PRÉCÉDENT", "user_validated": "Utilisateur validé !", @@ -248,5 +248,8 @@ "offline": "Hors ligne", "logout_success": "Vous avez été déconnecté avec succès!", "logout_failure": "Quelque chose s'est mal passé, veuillez réessayer après un certain temps", - "go_to_home": "Aller à la maison" + "go_to_home": "Aller à la maison", + "no_internet_connection": "Pas de connexion Internet!", + "connect_and_retry": "Veuillez vous connecter à Internet et réessayer.", + "retry": "RECOMMENCEZ" } \ No newline at end of file diff --git a/assets/l10n/app_hi.arb b/assets/l10n/app_hi.arb index 1d64e8d1e..859200cfc 100644 --- a/assets/l10n/app_hi.arb +++ b/assets/l10n/app_hi.arb @@ -18,7 +18,7 @@ "next_button": "अगला", "password": "पासवर्ड", "enter_password": "पासवर्ड दर्ज करें", - "forgot_password": "पासवर्ड भूल गए?", + "forgot_password": "पासवर्ड भूल गए", "login_button": "लॉगिन", "back_button": "वापस", "user_validated": "उपयोगकर्ता मान्य!", @@ -248,5 +248,8 @@ "offline": "ऑफलाइन", "logout_success": "आप सफलता पूर्वक लॉगआउट कर चुके हैं!", "logout_failure": "कुछ गलती हो गई है, कृपया कुछ समय बाद पुनः प्रयास करें", - "go_to_home": "होम पर जाएं" + "go_to_home": "होम पर जाएं", + "no_internet_connection": "कोई इंटरनेट कनेक्शन नहीं!", + "connect_and_retry": "कृपया इंटरनेट से जुड़ें और पुनः प्रयास करें।", + "retry": "पुन: प्रयास" } \ No newline at end of file diff --git a/assets/l10n/app_kn.arb b/assets/l10n/app_kn.arb index e701052dc..6f7d85e67 100644 --- a/assets/l10n/app_kn.arb +++ b/assets/l10n/app_kn.arb @@ -18,7 +18,7 @@ "next_button": "ಮುಂದೆ", "password": "ಪಾಸ್ ವರ್ಡ್", "enter_password": "ಪಾಸ್ ವರ್ಡ್ ನಮೂದಿಸಿ", - "forgot_password": "ಪಾಸ್ ವರ್ಡ್ ಮರೆತಿದ್ದೀರಾ?", + "forgot_password": "ಪಾಸ್ ವರ್ಡ್ ಮರೆತಿದ್ದೀರಾ", "login_button": "ಲಾಗಿನ್", "back_button": "ಹಿಂದೆ", "user_validated": "ಬಳಕೆದಾರ ಮೌಲ್ಯೀಕರಿಸಲಾಗಿದೆ!", @@ -248,5 +248,8 @@ "offline": "ಆಫ್ಲೈನ್", "logout_success": "ನೀವು ಯಶಸ್ವಿಯಾಗಿ ಲಾಗ್ ಔಟ್ ಆಗಿರುವಿರಿ!", "logout_failure": "ಏನೋ ತಪ್ಪಾಗಿದೆ, ದಯವಿಟ್ಟು ಸ್ವಲ್ಪ ಸಮಯದ ನಂತರ ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ", - "go_to_home": "ಮನೆಗೆ ಹೋಗು" + "go_to_home": "ಮನೆಗೆ ಹೋಗು", + "no_internet_connection": "ಇಂಟರ್ನೆಟ್ ಸಂಪರ್ಕವಿಲ್ಲ!", + "connect_and_retry": "ದಯವಿಟ್ಟು ಇಂಟರ್ನೆಟ್\u200Cನೊಂದಿಗೆ ಸಂಪರ್ಕಿಸಿ ಮತ್ತು ಮರುಪ್ರಯತ್ನಿಸಿ.", + "retry": "ಮರುಪ್ರಯತ್ನಿಸಿ" } \ No newline at end of file diff --git a/assets/l10n/app_ta.arb b/assets/l10n/app_ta.arb index 8133b03e6..fc5af70c5 100644 --- a/assets/l10n/app_ta.arb +++ b/assets/l10n/app_ta.arb @@ -18,7 +18,7 @@ "next_button": "அடுத்தவர்", "password": "அடையாளச் சொல்", "enter_password": "கடவுச்சொல்லை உள்ளிடவும்", - "forgot_password": "கடவுச்சொல் மறந்துவிட்டதா?", + "forgot_password": "கடவுச்சொல் மறந்துவிட்டதா", "login_button": "உள்நுழைவு", "back_button": "முதுகு", "user_validated": "பயனர் சரிபார்க்கப்பட்டது!", @@ -257,5 +257,8 @@ "offline": "ஆஃப்லைனில்", "logout_success": "நீங்கள் வெற்றிகரமாக வெளியேறிவிட்டீர்கள்!", "logout_failure": "ஏதோ தவறாகிவிட்டது, சிறிது நேரம் கழித்து மீண்டும் முயற்சிக்கவும்", - "go_to_home": "வீட்டிற்கு போ" + "go_to_home": "வீட்டிற்கு போ", + "no_internet_connection": "இணைய இணைப்பு இல்லை!", + "connect_and_retry": "இணையத்துடன் இணைத்து மீண்டும் முயற்சிக்கவும்.", + "retry": "மீண்டும் முயற்சிக்கவும்" } \ No newline at end of file diff --git a/assets/svg/No internet connection.svg b/assets/svg/No internet connection.svg new file mode 100644 index 000000000..20574cfcf --- /dev/null +++ b/assets/svg/No internet connection.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/lib/provider/auth_provider.dart b/lib/provider/auth_provider.dart index 7b602968d..7180cda11 100644 --- a/lib/provider/auth_provider.dart +++ b/lib/provider/auth_provider.dart @@ -30,6 +30,7 @@ class AuthProvider with ChangeNotifier { String _userId = ""; String _username = ""; String _userEmail = ""; + bool _isNetworkPresent = false; bool get isLoggedIn => _isLoggedIn; bool get isSyncing => _isSyncing; @@ -49,6 +50,7 @@ class AuthProvider with ChangeNotifier { String get userId => _userId; String get username => _username; String get userEmail => _userEmail; + bool get isNetworkPresent => _isNetworkPresent; setIsLoggedIn(bool value) { _isLoggedIn = value; @@ -207,4 +209,10 @@ class AuthProvider with ChangeNotifier { notifyListeners(); } + + setIsNetworkPresent(bool value){ + _isNetworkPresent = value; + notifyListeners(); + } + } diff --git a/lib/ui/login_page.dart b/lib/ui/login_page.dart index b6837d0c1..0149df30f 100644 --- a/lib/ui/login_page.dart +++ b/lib/ui/login_page.dart @@ -19,8 +19,10 @@ import 'package:registration_client/main.dart'; import 'package:registration_client/pigeon/user_pigeon.dart'; import 'package:registration_client/provider/auth_provider.dart'; +import 'package:registration_client/provider/registration_task_provider.dart'; import 'package:registration_client/provider/sync_provider.dart'; import 'package:registration_client/ui/dashboard/dashboard_tablet.dart'; +import 'package:registration_client/ui/widgets/network_component.dart'; import 'package:registration_client/ui/widgets/sync_alert_dialog.dart'; import 'package:registration_client/utils/app_style.dart'; import 'package:registration_client/ui/machine_keys.dart'; @@ -32,6 +34,7 @@ import 'package:registration_client/utils/responsive.dart'; import 'package:registration_client/ui/widgets/password_component.dart'; import 'package:registration_client/ui/widgets/username_component.dart'; import 'package:colorful_progress_indicators/colorful_progress_indicators.dart'; +import 'package:url_launcher/url_launcher.dart'; import '../utils/life_cycle_event_handler.dart'; @@ -337,6 +340,23 @@ class _LoginPageState extends State with WidgetsBindingObserver { return context.read().isConnected; } + goToUrl(String url) async { + if (await canLaunchUrl(Uri.parse(url))) { + await launchUrl(Uri.parse(url),mode: LaunchMode.externalApplication); + } else { + throw 'Could not launch $url'; + } + } + + _getStringValueGlobalParamAction(BuildContext context, String key) async { + await context + .read() + .getStringValueGlobalParam(key); + String res = + context.read().stringValueGlobalParam; + await goToUrl(res); + } + _getLoginAction() async { FocusManager.instance.primaryFocus?.unfocus(); if (password.isEmpty) { @@ -578,6 +598,7 @@ class _LoginPageState extends State with WidgetsBindingObserver { SizedBox( height: isMobile && !isMobileSize ? 16.h : 34.h, ), + if(!context.watch().isNetworkPresent)...[ Text( appLocalizations.login_text, style: isMobile && !isMobileSize @@ -587,7 +608,8 @@ class _LoginPageState extends State with WidgetsBindingObserver { SizedBox( height: context.watch().isValidUser ? 42.h : 38.h, ), - !context.watch().isValidUser + ], + !context.watch().isValidUser && !context.watch().isNetworkPresent ? UsernameComponent( onTap: () { _getUserValidation(); @@ -604,7 +626,7 @@ class _LoginPageState extends State with WidgetsBindingObserver { }, ) : const SizedBox(), - context.watch().isValidUser + context.watch().isValidUser && !context.watch().isNetworkPresent ? PasswordComponent( isDisabled: password.isEmpty || password.length > 50, onTapLogin: () async { @@ -621,6 +643,10 @@ class _LoginPageState extends State with WidgetsBindingObserver { authProvider.setIsSyncing(false); }); }, + onTapForgotPassword: () async { + // authProvider.setIsNetworkPresent(true); + _getStringValueGlobalParamAction(context, "mosip.registration.reset_password_url"); + }, onChanged: (v) { setState(() { password = v; @@ -629,6 +655,12 @@ class _LoginPageState extends State with WidgetsBindingObserver { isLoggingIn: authProvider.isSyncing, ) : const SizedBox(), + context.watch().isNetworkPresent? + NetworkComponent(isMobile: isMobile, + onTapRetry: (){ + authProvider.setIsNetworkPresent(false); + }) + : const SizedBox(), ], ), ); diff --git a/lib/ui/widgets/network_component.dart b/lib/ui/widgets/network_component.dart new file mode 100644 index 000000000..f0907f287 --- /dev/null +++ b/lib/ui/widgets/network_component.dart @@ -0,0 +1,68 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:registration_client/utils/app_style.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +import '../../utils/app_config.dart'; + +class NetworkComponent extends StatelessWidget { + const NetworkComponent({super.key, required this.isMobile, required this.onTapRetry}); + final bool isMobile; + final VoidCallback onTapRetry; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 10), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + height: 120, + child: SvgPicture.asset( + "assets/svg/No internet connection.svg"), + ), + SizedBox( + height: 30.h, + ), + Text(AppLocalizations.of(context)!.no_internet_connection, + style: const TextStyle(fontWeight: FontWeight.bold,color: Colors.black,fontSize: 26)), + SizedBox( + height: 5.h, + ), + Text(AppLocalizations.of(context)!.connect_and_retry, + textAlign: TextAlign.center, + style: const TextStyle(fontWeight: FontWeight.w300,color: Colors.grey,fontSize: 22)), + SizedBox( + height: 50.h, + ), + InkWell( + onTap: onTapRetry, + child: Container( + height: isMobile && !isMobileSize ? 82.h : 52.h, + decoration: BoxDecoration( + color: appSolidPrimary, + border: Border.all( + width: 1.w, + color: appBlueShade1, + ), + borderRadius: const BorderRadius.all( + Radius.circular(5), + ), + ), + child: Center( + child: Text( + AppLocalizations.of(context)!.retry, + style: isMobile + && !isMobileSize ? AppTextStyle.tabletPortraitButtonText + : AppTextStyle.mobileButtonText, + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/ui/widgets/password_component.dart b/lib/ui/widgets/password_component.dart index 860b52b63..aedf1106f 100644 --- a/lib/ui/widgets/password_component.dart +++ b/lib/ui/widgets/password_component.dart @@ -20,6 +20,7 @@ class PasswordComponent extends StatelessWidget { required this.isLoggingIn, required this.isDisabled, required this.isMobile, + required this.onTapForgotPassword, }) : super(key: key); final VoidCallback onTapLogin; @@ -28,6 +29,7 @@ class PasswordComponent extends StatelessWidget { final bool isLoggingIn; final bool isDisabled; final bool isMobile; + final VoidCallback onTapForgotPassword; @override Widget build(BuildContext context) { @@ -83,21 +85,21 @@ class PasswordComponent extends StatelessWidget { ), ), ), - SizedBox( - height: 15.h, - ), - InkWell( - onTap: () {}, - child: Container( - alignment: Alignment.centerRight, - child: Text( - AppLocalizations.of(context)!.forgot_password, - style: isMobile - && !isMobileSize ? AppTextStyle.tabletPortraitForgotPasswordText - : AppTextStyle.mobileForgotPasswordText, - ), - ), - ), + // SizedBox( + // height: 15.h, + // ), + // InkWell( + // onTap: () {}, + // child: Container( + // alignment: Alignment.centerRight, + // child: Text( + // AppLocalizations.of(context)!.forgot_password, + // style: isMobile + // && !isMobileSize ? AppTextStyle.tabletPortraitForgotPasswordText + // : AppTextStyle.mobileForgotPasswordText, + // ), + // ), + // ), SizedBox( height: 30.h, ), @@ -161,6 +163,24 @@ class PasswordComponent extends StatelessWidget { ), ), ), + SizedBox( + height: 30.h, + ), + InkWell( + onTap: onTapForgotPassword, + child: Container( + alignment: Alignment.center, + child: Text( + AppLocalizations.of(context)!.forgot_password, + style: isMobile + && !isMobileSize ? AppTextStyle.tabletPortraitForgotPasswordText + : AppTextStyle.mobileForgotPasswordText, + ), + ), + ), + SizedBox( + height: 20.h, + ), ], ); } From 4a5a9e2ca5b9c798d462dc646256c1b8a8024067 Mon Sep 17 00:00:00 2001 From: Sachin S P Date: Wed, 24 Jul 2024 17:08:31 +0530 Subject: [PATCH 2/5] forgot password keycloak url integarted Signed-off-by: Sachin S P --- .../api_services/AuthenticationApi.java | 7 ++++ android/build.gradle | 1 + android/clientmanager/build.gradle | 1 + lib/platform_android/auth_service_impl.dart | 13 +++++++ lib/platform_spi/auth_service.dart | 2 ++ lib/provider/auth_provider.dart | 8 +++++ lib/ui/login_page.dart | 35 ++++++++++++------- pigeon/auth_response.dart | 2 ++ 8 files changed, 56 insertions(+), 13 deletions(-) diff --git a/android/app/src/main/java/io/mosip/registration_client/api_services/AuthenticationApi.java b/android/app/src/main/java/io/mosip/registration_client/api_services/AuthenticationApi.java index 00af9329c..16fb93c63 100644 --- a/android/app/src/main/java/io/mosip/registration_client/api_services/AuthenticationApi.java +++ b/android/app/src/main/java/io/mosip/registration_client/api_services/AuthenticationApi.java @@ -24,6 +24,7 @@ import javax.inject.Inject; import javax.inject.Singleton; +import io.mosip.registration.clientmanager.BuildConfig; import io.mosip.registration.clientmanager.constant.AuditEvent; import io.mosip.registration.clientmanager.constant.Components; import io.mosip.registration.clientmanager.dto.http.ResponseWrapper; @@ -232,4 +233,10 @@ public void stopAlarmService(@NonNull AuthResponsePigeon.Result result) } result.success(resultString); } + + @Override + public void forgotPasswordUrl(@NonNull AuthResponsePigeon.Result result) { + String response = "https://"+ BuildConfig.FORGOT_PASSWORD_URL +"/auth/realms/master/protocol/openid-connect/auth?client_id=security-admin-console&redirect_uri=https%3A%2F%2F"+ BuildConfig.FORGOT_PASSWORD_URL +"%2Fauth%2Fadmin%2Fmaster%2Fconsole%2F&state=744b7212-725b-48cb-91a9-9b8e4c33a031&response_mode=fragment&response_type=code&scope=openid&nonce=08339536-3d88-4d24-a465-16e9d02e7dbe&code_challenge=OQREJKeFfdANcrZpB10WqFQe8Y2Br881eR628O1sJnU&code_challenge_method=S256"; + result.success(response); + } } diff --git a/android/build.gradle b/android/build.gradle index 9b4be4ae0..217cc77ef 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -43,6 +43,7 @@ ext { serverHealthCheckPath = "\"/v1/syncdata/actuator/health\"" serverActuatorInfoPath = "\"/v1/syncdata/actuator/info\"" debugPassword = "\"APTyKejHxACQyKBSRciR\"" + serverForgotPasswordURL = "\"iam.qa-platform1.mosip.net\"" } diff --git a/android/clientmanager/build.gradle b/android/clientmanager/build.gradle index 0acc49d35..ae95f3313 100644 --- a/android/clientmanager/build.gradle +++ b/android/clientmanager/build.gradle @@ -20,6 +20,7 @@ android { buildConfigField("String", "CLIENT_VERSION", rootProject.ext.clientmanagerLibVersionName) buildConfigField("String", "BASE_URL", rootProject.ext.serverBaseURL) buildConfigField("String", "DEBUG_PASSWORD", rootProject.ext.debugPassword) + buildConfigField("String", "FORGOT_PASSWORD_URL", rootProject.ext.serverForgotPasswordURL) } buildTypes { diff --git a/lib/platform_android/auth_service_impl.dart b/lib/platform_android/auth_service_impl.dart index b161c207e..c8478ddc6 100644 --- a/lib/platform_android/auth_service_impl.dart +++ b/lib/platform_android/auth_service_impl.dart @@ -85,6 +85,19 @@ class AuthServiceImpl implements AuthService { return stopAlarmServiceResponse; } + @override + Future forgotPasswordUrl() async{ + late String forgotPasswordResponse; + try { + forgotPasswordResponse = await AuthResponseApi().forgotPasswordUrl(); + } on PlatformException { + debugPrint('forgotPassword call failed!'); + } catch (e) { + debugPrint(e.toString()); + } + return forgotPasswordResponse; + } + } diff --git a/lib/platform_spi/auth_service.dart b/lib/platform_spi/auth_service.dart index 5654156e6..bf3fce5db 100644 --- a/lib/platform_spi/auth_service.dart +++ b/lib/platform_spi/auth_service.dart @@ -23,5 +23,7 @@ abstract class AuthService { Future stopAlarmService(); + Future forgotPasswordUrl(); + factory AuthService() => getAuthServiceImpl(); } diff --git a/lib/provider/auth_provider.dart b/lib/provider/auth_provider.dart index 7180cda11..3592d8342 100644 --- a/lib/provider/auth_provider.dart +++ b/lib/provider/auth_provider.dart @@ -31,6 +31,7 @@ class AuthProvider with ChangeNotifier { String _username = ""; String _userEmail = ""; bool _isNetworkPresent = false; + String _forgotPasswordUrl = ""; bool get isLoggedIn => _isLoggedIn; bool get isSyncing => _isSyncing; @@ -51,6 +52,7 @@ class AuthProvider with ChangeNotifier { String get username => _username; String get userEmail => _userEmail; bool get isNetworkPresent => _isNetworkPresent; + String get forgotPasswordUrl => _forgotPasswordUrl; setIsLoggedIn(bool value) { _isLoggedIn = value; @@ -215,4 +217,10 @@ class AuthProvider with ChangeNotifier { notifyListeners(); } + getForgotPasswordUrl() async { + String forgotPasswordUrl = await auth.forgotPasswordUrl(); + _forgotPasswordUrl = forgotPasswordUrl; + notifyListeners(); + } + } diff --git a/lib/ui/login_page.dart b/lib/ui/login_page.dart index 0149df30f..3a184738d 100644 --- a/lib/ui/login_page.dart +++ b/lib/ui/login_page.dart @@ -348,15 +348,6 @@ class _LoginPageState extends State with WidgetsBindingObserver { } } - _getStringValueGlobalParamAction(BuildContext context, String key) async { - await context - .read() - .getStringValueGlobalParam(key); - String res = - context.read().stringValueGlobalParam; - await goToUrl(res); - } - _getLoginAction() async { FocusManager.instance.primaryFocus?.unfocus(); if (password.isEmpty) { @@ -644,8 +635,17 @@ class _LoginPageState extends State with WidgetsBindingObserver { }); }, onTapForgotPassword: () async { - // authProvider.setIsNetworkPresent(true); - _getStringValueGlobalParamAction(context, "mosip.registration.reset_password_url"); + await connectivityProvider + .checkNetworkConnection(); + bool isConnected = + connectivityProvider.isConnected; + if(isConnected) { + await authProvider.getForgotPasswordUrl(); + String res = authProvider.forgotPasswordUrl; + await goToUrl(res); + } else { + authProvider.setIsNetworkPresent(true); + } }, onChanged: (v) { setState(() { @@ -657,8 +657,17 @@ class _LoginPageState extends State with WidgetsBindingObserver { : const SizedBox(), context.watch().isNetworkPresent? NetworkComponent(isMobile: isMobile, - onTapRetry: (){ - authProvider.setIsNetworkPresent(false); + onTapRetry: () async{ + await connectivityProvider + .checkNetworkConnection(); + bool isConnected = + connectivityProvider.isConnected; + if(isConnected) { + authProvider.setIsNetworkPresent(false); + await authProvider.getForgotPasswordUrl(); + String res = authProvider.forgotPasswordUrl; + await goToUrl(res); + } }) : const SizedBox(), ], diff --git a/pigeon/auth_response.dart b/pigeon/auth_response.dart index b98c119b9..2c143718f 100644 --- a/pigeon/auth_response.dart +++ b/pigeon/auth_response.dart @@ -32,4 +32,6 @@ abstract class AuthResponseApi { String logout(); @async String stopAlarmService(); + @async + String forgotPasswordUrl(); } From c9285db70e25f67a40f8793ca1e669f05b1ae5a2 Mon Sep 17 00:00:00 2001 From: Sachin S P Date: Fri, 2 Aug 2024 12:14:15 +0530 Subject: [PATCH 3/5] network component alignment issue Signed-off-by: Sachin S P --- lib/ui/widgets/network_component.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ui/widgets/network_component.dart b/lib/ui/widgets/network_component.dart index f0907f287..0be31fa76 100644 --- a/lib/ui/widgets/network_component.dart +++ b/lib/ui/widgets/network_component.dart @@ -14,17 +14,17 @@ class NetworkComponent extends StatelessWidget { @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.only(top: 80,bottom: 20), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( - height: 120, + height: 130, child: SvgPicture.asset( "assets/svg/No internet connection.svg"), ), SizedBox( - height: 30.h, + height: 50.h, ), Text(AppLocalizations.of(context)!.no_internet_connection, style: const TextStyle(fontWeight: FontWeight.bold,color: Colors.black,fontSize: 26)), @@ -35,7 +35,7 @@ class NetworkComponent extends StatelessWidget { textAlign: TextAlign.center, style: const TextStyle(fontWeight: FontWeight.w300,color: Colors.grey,fontSize: 22)), SizedBox( - height: 50.h, + height: 90.h, ), InkWell( onTap: onTapRetry, From 284e278849b50f04317317c53ce2114fd26425e3 Mon Sep 17 00:00:00 2001 From: Sachin S P Date: Tue, 7 Jan 2025 14:35:32 +0530 Subject: [PATCH 4/5] RCF-69 fetching the value from configue properties Signed-off-by: Sachin S P --- .../registration_client/HostApiModule.java | 4 +- .../api_services/AuthenticationApi.java | 8 ++- android/build.gradle | 1 - android/clientmanager/build.gradle | 1 - .../constant/RegistrationConstants.java | 1 + .../repository/GlobalParamRepository.java | 4 ++ lib/ui/login_page.dart | 61 +++++++++++++++---- 7 files changed, 63 insertions(+), 17 deletions(-) diff --git a/android/app/src/main/java/io/mosip/registration_client/HostApiModule.java b/android/app/src/main/java/io/mosip/registration_client/HostApiModule.java index a369a7fcc..3866fc182 100644 --- a/android/app/src/main/java/io/mosip/registration_client/HostApiModule.java +++ b/android/app/src/main/java/io/mosip/registration_client/HostApiModule.java @@ -113,9 +113,9 @@ MachineDetailsApi getMachineDetailsApi(ClientCryptoManagerService clientCryptoMa AuthenticationApi getAuthenticationApi(SyncRestService syncRestService, SyncRestUtil syncRestFactory, LoginService loginService, - AuditManagerService auditManagerService) { + AuditManagerService auditManagerService,GlobalParamRepository globalParamRepository) { return new AuthenticationApi(appContext, syncRestService, syncRestFactory, - loginService, auditManagerService); + loginService, auditManagerService, globalParamRepository); } @Provides diff --git a/android/app/src/main/java/io/mosip/registration_client/api_services/AuthenticationApi.java b/android/app/src/main/java/io/mosip/registration_client/api_services/AuthenticationApi.java index 16fb93c63..22f301dee 100644 --- a/android/app/src/main/java/io/mosip/registration_client/api_services/AuthenticationApi.java +++ b/android/app/src/main/java/io/mosip/registration_client/api_services/AuthenticationApi.java @@ -30,6 +30,7 @@ import io.mosip.registration.clientmanager.dto.http.ResponseWrapper; import io.mosip.registration.clientmanager.dto.http.ServiceError; import io.mosip.registration.clientmanager.exception.InvalidMachineSpecIDException; +import io.mosip.registration.clientmanager.repository.GlobalParamRepository; import io.mosip.registration.clientmanager.service.LoginService; import io.mosip.registration.clientmanager.spi.AuditManagerService; import io.mosip.registration.clientmanager.spi.SyncRestService; @@ -49,6 +50,7 @@ public class AuthenticationApi implements AuthResponsePigeon.AuthResponseApi { LoginService loginService; AuditManagerService auditManagerService; SharedPreferences sharedPreferences; + GlobalParamRepository globalParamRepository; public static final String IS_OFFICER = "is_officer"; public static final String IS_SUPERVISOR = "is_supervisor"; public static final String IS_DEFAULT = "is_default"; @@ -60,12 +62,13 @@ public class AuthenticationApi implements AuthResponsePigeon.AuthResponseApi { @Inject public AuthenticationApi(Context context, SyncRestService syncRestService, SyncRestUtil syncRestFactory, - LoginService loginService, AuditManagerService auditManagerService) { + LoginService loginService, AuditManagerService auditManagerService, GlobalParamRepository globalParamRepository) { this.context = context; this.syncRestService = syncRestService; this.syncRestFactory = syncRestFactory; this.loginService = loginService; this.auditManagerService = auditManagerService; + this.globalParamRepository = globalParamRepository; sharedPreferences = this.context. getSharedPreferences( this.context.getString(R.string.app_name), @@ -236,7 +239,8 @@ public void stopAlarmService(@NonNull AuthResponsePigeon.Result result) @Override public void forgotPasswordUrl(@NonNull AuthResponsePigeon.Result result) { - String response = "https://"+ BuildConfig.FORGOT_PASSWORD_URL +"/auth/realms/master/protocol/openid-connect/auth?client_id=security-admin-console&redirect_uri=https%3A%2F%2F"+ BuildConfig.FORGOT_PASSWORD_URL +"%2Fauth%2Fadmin%2Fmaster%2Fconsole%2F&state=744b7212-725b-48cb-91a9-9b8e4c33a031&response_mode=fragment&response_type=code&scope=openid&nonce=08339536-3d88-4d24-a465-16e9d02e7dbe&code_challenge=OQREJKeFfdANcrZpB10WqFQe8Y2Br881eR628O1sJnU&code_challenge_method=S256"; + System.out.println("<======forgot password url======>"+this.globalParamRepository.getCachedStringForgotPassword()); + String response = this.globalParamRepository.getCachedStringForgotPassword(); result.success(response); } } diff --git a/android/build.gradle b/android/build.gradle index f7cc9bdc8..7c169ab6c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -43,7 +43,6 @@ ext { serverHealthCheckPath = "\"/v1/syncdata/actuator/health\"" serverActuatorInfoPath = "\"/v1/syncdata/actuator/info\"" debugPassword = "\"APTyKejHxACQyKBSRciR\"" - serverForgotPasswordURL = "\"iam.qa-platform1.mosip.net\"" } diff --git a/android/clientmanager/build.gradle b/android/clientmanager/build.gradle index f9ead06dc..6a14f421c 100644 --- a/android/clientmanager/build.gradle +++ b/android/clientmanager/build.gradle @@ -20,7 +20,6 @@ android { buildConfigField("String", "CLIENT_VERSION", rootProject.ext.clientmanagerLibVersionName) buildConfigField("String", "BASE_URL", rootProject.ext.serverBaseURL) buildConfigField("String", "DEBUG_PASSWORD", rootProject.ext.debugPassword) - buildConfigField("String", "FORGOT_PASSWORD_URL", rootProject.ext.serverForgotPasswordURL) } buildTypes { diff --git a/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/constant/RegistrationConstants.java b/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/constant/RegistrationConstants.java index 19bade065..a0a0f6ace 100644 --- a/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/constant/RegistrationConstants.java +++ b/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/constant/RegistrationConstants.java @@ -90,4 +90,5 @@ public class RegistrationConstants { public static final String SELECTED_HANDLES = "mosip.registration.default-selected-handle-fields"; public static final String TEMPLATE_IMPORTANT_GUIDELINES = "mosip.registration.important_guidelines"; public static final String PRE_REG_PACKET_LOCATION = "mosip.registration.registration_pre_reg_packet_location"; + public static final String FORGOT_PASSWORD_URL = "mosip.registration.reset_password_url"; } diff --git a/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/repository/GlobalParamRepository.java b/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/repository/GlobalParamRepository.java index 6c2764308..9138bbcb2 100644 --- a/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/repository/GlobalParamRepository.java +++ b/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/repository/GlobalParamRepository.java @@ -118,4 +118,8 @@ public List getSelectedHandles() { .distinct() .collect(Collectors.toList()); } + + public String getCachedStringForgotPassword() { + return globalParamMap.get(RegistrationConstants.FORGOT_PASSWORD_URL); + } } diff --git a/lib/ui/login_page.dart b/lib/ui/login_page.dart index 44e74e0a5..fb9730971 100644 --- a/lib/ui/login_page.dart +++ b/lib/ui/login_page.dart @@ -21,6 +21,7 @@ import 'package:registration_client/pigeon/user_pigeon.dart'; import 'package:registration_client/provider/auth_provider.dart'; import 'package:registration_client/provider/sync_provider.dart'; import 'package:registration_client/ui/dashboard/dashboard_tablet.dart'; +import 'package:registration_client/ui/widgets/network_component.dart'; import 'package:registration_client/ui/widgets/sync_alert_dialog.dart'; import 'package:registration_client/utils/app_style.dart'; import 'package:registration_client/ui/machine_keys.dart'; @@ -32,6 +33,7 @@ import 'package:registration_client/utils/responsive.dart'; import 'package:registration_client/ui/widgets/password_component.dart'; import 'package:registration_client/ui/widgets/username_component.dart'; import 'package:colorful_progress_indicators/colorful_progress_indicators.dart'; +import 'package:url_launcher/url_launcher.dart'; import '../utils/life_cycle_event_handler.dart'; @@ -260,6 +262,14 @@ class _LoginPageState extends State with WidgetsBindingObserver { ); } + goToUrl(String url) async { + if (await canLaunchUrl(Uri.parse(url))) { + await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication); + } else { + throw 'Could not launch $url'; + } + } + _getLoginAction() async { ScaffoldMessenger.of(context).hideCurrentSnackBar(); FocusManager.instance.primaryFocus?.unfocus(); @@ -471,16 +481,19 @@ class _LoginPageState extends State with WidgetsBindingObserver { SizedBox( height: isMobile && !isMobileSize ? 16.h : 34.h, ), - Text( - appLocalizations.login_text, - style: isMobile && !isMobileSize - ? AppTextStyle.tabletPortraitHeaderText - : AppTextStyle.mobileHeaderText, - ), - SizedBox( - height: context.watch().isValidUser ? 42.h : 38.h, - ), - !context.watch().isValidUser + if (!context.watch().isNetworkPresent) ...[ + Text( + appLocalizations.login_text, + style: isMobile && !isMobileSize + ? AppTextStyle.tabletPortraitHeaderText + : AppTextStyle.mobileHeaderText, + ), + SizedBox( + height: context.watch().isValidUser ? 42.h : 38.h, + ), + ], + !context.watch().isValidUser && + !context.watch().isNetworkPresent ? UsernameComponent( onTap: () { _getUserValidation(); @@ -497,7 +510,8 @@ class _LoginPageState extends State with WidgetsBindingObserver { }, ) : const SizedBox(), - context.watch().isValidUser + context.watch().isValidUser && + !context.watch().isNetworkPresent ? PasswordComponent( isDisabled: password.isEmpty || password.length > 50, onTapLogin: () async { @@ -514,6 +528,17 @@ class _LoginPageState extends State with WidgetsBindingObserver { authProvider.setIsSyncing(false); }); }, + onTapForgotPassword: () async { + await connectivityProvider.checkNetworkConnection(); + bool isConnected = connectivityProvider.isConnected; + if (isConnected) { + await authProvider.getForgotPasswordUrl(); + String res = authProvider.forgotPasswordUrl; + await goToUrl(res); + } else { + authProvider.setIsNetworkPresent(true); + } + }, onChanged: (v) { setState(() { password = v; @@ -522,6 +547,20 @@ class _LoginPageState extends State with WidgetsBindingObserver { isLoggingIn: authProvider.isSyncing, ) : const SizedBox(), + context.watch().isNetworkPresent + ? NetworkComponent( + isMobile: isMobile, + onTapRetry: () async { + await connectivityProvider.checkNetworkConnection(); + bool isConnected = connectivityProvider.isConnected; + if (isConnected) { + authProvider.setIsNetworkPresent(false); + await authProvider.getForgotPasswordUrl(); + String res = authProvider.forgotPasswordUrl; + await goToUrl(res); + } + }) + : const SizedBox(), ], ), ); From 8f842a40db5135d245909671049a2dfafdb7ce85 Mon Sep 17 00:00:00 2001 From: Sachin S P Date: Tue, 7 Jan 2025 17:25:41 +0530 Subject: [PATCH 5/5] RCF-69 fetching the value from configue properties Signed-off-by: Sachin S P --- assets/l10n/app_ar.arb | 2 +- assets/l10n/app_en.arb | 2 +- assets/l10n/app_fr.arb | 2 +- assets/l10n/app_hi.arb | 2 +- assets/l10n/app_kn.arb | 2 +- assets/l10n/app_ta.arb | 2 +- lib/ui/widgets/network_component.dart | 4 ++-- lib/utils/app_style.dart | 4 ++-- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/assets/l10n/app_ar.arb b/assets/l10n/app_ar.arb index 8cb28a564..8ee742fec 100644 --- a/assets/l10n/app_ar.arb +++ b/assets/l10n/app_ar.arb @@ -18,7 +18,7 @@ "next_button": "مقبل", "password": "شعار", "enter_password": "أدخل كلمة المرور", - "forgot_password": "نسيت كلمة المرور", + "forgot_password": "هل نسيت كلمة السر؟", "login_button": "تسجيل الدخول", "back_button": "ظهر", "user_validated": "تم التحقق من صحة المستخدم!", diff --git a/assets/l10n/app_en.arb b/assets/l10n/app_en.arb index ecde59abd..440854f6d 100644 --- a/assets/l10n/app_en.arb +++ b/assets/l10n/app_en.arb @@ -18,7 +18,7 @@ "next_button": "NEXT", "password": "Password", "enter_password": "Enter Password", - "forgot_password": "FORGOT PASSWORD", + "forgot_password": "FORGOT PASSWORD?", "login_button": "LOGIN", "back_button": "BACK", "user_validated": "User Validated!", diff --git a/assets/l10n/app_fr.arb b/assets/l10n/app_fr.arb index 31e5541cf..99001ccfc 100644 --- a/assets/l10n/app_fr.arb +++ b/assets/l10n/app_fr.arb @@ -18,7 +18,7 @@ "next_button": "PROCHAINE", "password": "Mot de passe", "enter_password": "Entrez le mot de passe", - "forgot_password": "MOT DE PASSE OUBLIÉ", + "forgot_password": "MOT DE PASSE OUBLIÉ ?", "login_button": "CONNECTEZ-VOUS", "back_button": "PRÉCÉDENT", "user_validated": "Utilisateur validé !", diff --git a/assets/l10n/app_hi.arb b/assets/l10n/app_hi.arb index 20f5a8c22..e4114c44c 100644 --- a/assets/l10n/app_hi.arb +++ b/assets/l10n/app_hi.arb @@ -18,7 +18,7 @@ "next_button": "अगला", "password": "पासवर्ड", "enter_password": "पासवर्ड दर्ज करें", - "forgot_password": "पासवर्ड भूल गए", + "forgot_password": "पासवर्ड भूल गए?", "login_button": "लॉगिन", "back_button": "वापस", "user_validated": "उपयोगकर्ता मान्य!", diff --git a/assets/l10n/app_kn.arb b/assets/l10n/app_kn.arb index 9c2663c1e..c23060d82 100644 --- a/assets/l10n/app_kn.arb +++ b/assets/l10n/app_kn.arb @@ -18,7 +18,7 @@ "next_button": "ಮುಂದೆ", "password": "ಪಾಸ್ ವರ್ಡ್", "enter_password": "ಪಾಸ್ ವರ್ಡ್ ನಮೂದಿಸಿ", - "forgot_password": "ಪಾಸ್ ವರ್ಡ್ ಮರೆತಿದ್ದೀರಾ", + "forgot_password": "ಪಾಸ್ವರ್ಡ್ ಮರೆತಿರುವಿರಾ?", "login_button": "ಲಾಗಿನ್", "back_button": "ಹಿಂದೆ", "user_validated": "ಬಳಕೆದಾರ ಮೌಲ್ಯೀಕರಿಸಲಾಗಿದೆ!", diff --git a/assets/l10n/app_ta.arb b/assets/l10n/app_ta.arb index 447ea434e..b84be2026 100644 --- a/assets/l10n/app_ta.arb +++ b/assets/l10n/app_ta.arb @@ -18,7 +18,7 @@ "next_button": "அடுத்தவர்", "password": "அடையாளச் சொல்", "enter_password": "கடவுச்சொல்லை உள்ளிடவும்", - "forgot_password": "கடவுச்சொல் மறந்துவிட்டதா", + "forgot_password": "கடவுச்சொல்லை மறந்துவிட்டீர்களா?", "login_button": "உள்நுழைவு", "back_button": "முதுகு", "user_validated": "பயனர் சரிபார்க்கப்பட்டது!", diff --git a/lib/ui/widgets/network_component.dart b/lib/ui/widgets/network_component.dart index 0be31fa76..6cbe80f68 100644 --- a/lib/ui/widgets/network_component.dart +++ b/lib/ui/widgets/network_component.dart @@ -14,7 +14,7 @@ class NetworkComponent extends StatelessWidget { @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.only(top: 80,bottom: 20), + padding: const EdgeInsets.only(top: 50,bottom: 20), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -35,7 +35,7 @@ class NetworkComponent extends StatelessWidget { textAlign: TextAlign.center, style: const TextStyle(fontWeight: FontWeight.w300,color: Colors.grey,fontSize: 22)), SizedBox( - height: 90.h, + height: 50.h, ), InkWell( onTap: onTapRetry, diff --git a/lib/utils/app_style.dart b/lib/utils/app_style.dart index 110ca4c83..79f8b511a 100644 --- a/lib/utils/app_style.dart +++ b/lib/utils/app_style.dart @@ -81,7 +81,7 @@ abstract class AppTextStyle { ); static TextStyle mobileForgotPasswordText = const TextStyle( - fontWeight: FontWeight.w500, + fontWeight: FontWeight.bold, fontSize: 14, color: appSolidPrimary, letterSpacing: 0.5, @@ -284,7 +284,7 @@ abstract class AppTextStyle { ); static TextStyle tabletPortraitForgotPasswordText = const TextStyle( - fontWeight: FontWeight.w500, + fontWeight: FontWeight.bold, fontSize: 22, color: appSolidPrimary, letterSpacing: 0.5,