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 7ca4a7105..c42625f66 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 @@ -22,4 +22,6 @@ UserDetailsApi getLoginActivityApi(LoginService loginService) { MachineDetailsApi getMachineDetailsApi(ClientCryptoManagerService clientCryptoManagerService) { return new MachineDetailsApi(clientCryptoManagerService); } + + } diff --git a/android/app/src/main/java/io/mosip/registration_client/api_services/UserDetailsApi.java b/android/app/src/main/java/io/mosip/registration_client/api_services/UserDetailsApi.java index 39392e036..956484334 100644 --- a/android/app/src/main/java/io/mosip/registration_client/api_services/UserDetailsApi.java +++ b/android/app/src/main/java/io/mosip/registration_client/api_services/UserDetailsApi.java @@ -20,6 +20,9 @@ public UserDetailsApi(LoginService loginService) { this.loginService = loginService; } + public void logout(){ + loginService.clearAuthToken(); + } public void usernameValidation(String username) { if(username == null || username.trim().length() == 0){ user = new UserPigeon.User.Builder() @@ -66,4 +69,10 @@ public UserPigeon.User validateUser(@NonNull String username) { usernameValidation(username); return user; } + @NonNull + @Override + public UserPigeon.User logoutUser() { + logout(); + return user; + } } \ No newline at end of file diff --git a/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/SessionManager.java b/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/SessionManager.java index 4a528fa71..64cdb7f21 100644 --- a/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/SessionManager.java +++ b/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/SessionManager.java @@ -60,6 +60,15 @@ public List saveAuthToken(@NonNull String token) throws Exception { return roles; } + public String clearAuthToken(){ + SharedPreferences.Editor editor = this.context.getSharedPreferences(this.context.getString(R.string.app_name), + Context.MODE_PRIVATE).edit(); + editor.clear(); + editor.apply(); + return this.context.getSharedPreferences(this.context.getString(R.string.app_name), + Context.MODE_PRIVATE).getString(USER_TOKEN, null); + } + public String fetchAuthToken() { return this.context.getSharedPreferences(this.context.getString(R.string.app_name), Context.MODE_PRIVATE).getString(USER_TOKEN, null); diff --git a/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/LoginService.java b/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/LoginService.java index 4c357e2fd..963550a27 100644 --- a/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/LoginService.java +++ b/android/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/LoginService.java @@ -21,10 +21,11 @@ import javax.inject.Inject; import javax.inject.Singleton; +import java.util.logging.Logger; @Singleton public class LoginService { - + private static final Logger LOGGER = Logger.getLogger(LoginService.class.getName()); private static final String TAG = LoginService.class.getSimpleName(); private SessionManager sessionManager; @@ -81,4 +82,16 @@ public List saveAuthToken(String authResponse) throws Exception { throw ex; } } + public String clearAuthToken(){ + try{ + String AuthTokenReturned=this.sessionManager.clearAuthToken(); + LOGGER.info("Auth Token is cleared and its value is "+AuthTokenReturned); + return AuthTokenReturned; + }catch (Exception ex) { + Log.e(TAG, ex.getMessage(), ex); + throw ex; + } + + + } } diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig index 592ceee85..ec97fc6f3 100644 --- a/ios/Flutter/Debug.xcconfig +++ b/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig index 592ceee85..c4855bfe2 100644 --- a/ios/Flutter/Release.xcconfig +++ b/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 000000000..88359b225 --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '11.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/ios/Runner/pigeon.h b/ios/Runner/pigeon.h index d1fe15a1d..374b1cad0 100644 --- a/ios/Runner/pigeon.h +++ b/ios/Runner/pigeon.h @@ -10,25 +10,33 @@ NS_ASSUME_NONNULL_BEGIN -@class Machine; +@class AuthResponse; -@interface Machine : NSObject +@interface AuthResponse : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithMap:(NSDictionary *)map ++ (instancetype)makeWithResponse:(NSString *)response + username:(NSString *)username + isOfficer:(NSNumber *)isOfficer + isDefault:(NSNumber *)isDefault + isSupervisor:(NSNumber *)isSupervisor errorCode:(nullable NSString *)errorCode; -@property(nonatomic, strong) NSDictionary * map; +@property(nonatomic, copy) NSString * response; +@property(nonatomic, copy) NSString * username; +@property(nonatomic, strong) NSNumber * isOfficer; +@property(nonatomic, strong) NSNumber * isDefault; +@property(nonatomic, strong) NSNumber * isSupervisor; @property(nonatomic, copy, nullable) NSString * errorCode; @end -/// The codec used by MachineApi. -NSObject *MachineApiGetCodec(void); +/// The codec used by AuthResponseApi. +NSObject *AuthResponseApiGetCodec(void); -@protocol MachineApi +@protocol AuthResponseApi /// @return `nil` only when `error != nil`. -- (nullable Machine *)getMachineDetailsWithError:(FlutterError *_Nullable *_Nonnull)error; +- (nullable AuthResponse *)loginUsername:(NSString *)username password:(NSString *)password isConnected:(NSNumber *)isConnected error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void MachineApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void AuthResponseApiSetup(id binaryMessenger, NSObject *_Nullable api); NS_ASSUME_NONNULL_END diff --git a/ios/Runner/pigeon.m b/ios/Runner/pigeon.m index 69ebdc75f..6f18f8756 100644 --- a/ios/Runner/pigeon.m +++ b/ios/Runner/pigeon.m @@ -21,56 +21,76 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { return (result == [NSNull null]) ? nil : result; } -@interface Machine () -+ (Machine *)fromList:(NSArray *)list; -+ (nullable Machine *)nullableFromList:(NSArray *)list; +@interface AuthResponse () ++ (AuthResponse *)fromList:(NSArray *)list; ++ (nullable AuthResponse *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@implementation Machine -+ (instancetype)makeWithMap:(NSDictionary *)map +@implementation AuthResponse ++ (instancetype)makeWithResponse:(NSString *)response + username:(NSString *)username + isOfficer:(NSNumber *)isOfficer + isDefault:(NSNumber *)isDefault + isSupervisor:(NSNumber *)isSupervisor errorCode:(nullable NSString *)errorCode { - Machine* pigeonResult = [[Machine alloc] init]; - pigeonResult.map = map; + AuthResponse* pigeonResult = [[AuthResponse alloc] init]; + pigeonResult.response = response; + pigeonResult.username = username; + pigeonResult.isOfficer = isOfficer; + pigeonResult.isDefault = isDefault; + pigeonResult.isSupervisor = isSupervisor; pigeonResult.errorCode = errorCode; return pigeonResult; } -+ (Machine *)fromList:(NSArray *)list { - Machine *pigeonResult = [[Machine alloc] init]; - pigeonResult.map = GetNullableObjectAtIndex(list, 0); - NSAssert(pigeonResult.map != nil, @""); - pigeonResult.errorCode = GetNullableObjectAtIndex(list, 1); ++ (AuthResponse *)fromList:(NSArray *)list { + AuthResponse *pigeonResult = [[AuthResponse alloc] init]; + pigeonResult.response = GetNullableObjectAtIndex(list, 0); + NSAssert(pigeonResult.response != nil, @""); + pigeonResult.username = GetNullableObjectAtIndex(list, 1); + NSAssert(pigeonResult.username != nil, @""); + pigeonResult.isOfficer = GetNullableObjectAtIndex(list, 2); + NSAssert(pigeonResult.isOfficer != nil, @""); + pigeonResult.isDefault = GetNullableObjectAtIndex(list, 3); + NSAssert(pigeonResult.isDefault != nil, @""); + pigeonResult.isSupervisor = GetNullableObjectAtIndex(list, 4); + NSAssert(pigeonResult.isSupervisor != nil, @""); + pigeonResult.errorCode = GetNullableObjectAtIndex(list, 5); return pigeonResult; } -+ (nullable Machine *)nullableFromList:(NSArray *)list { - return (list) ? [Machine fromList:list] : nil; ++ (nullable AuthResponse *)nullableFromList:(NSArray *)list { + return (list) ? [AuthResponse fromList:list] : nil; } - (NSArray *)toList { return @[ - (self.map ?: [NSNull null]), + (self.response ?: [NSNull null]), + (self.username ?: [NSNull null]), + (self.isOfficer ?: [NSNull null]), + (self.isDefault ?: [NSNull null]), + (self.isSupervisor ?: [NSNull null]), (self.errorCode ?: [NSNull null]), ]; } @end -@interface MachineApiCodecReader : FlutterStandardReader +@interface AuthResponseApiCodecReader : FlutterStandardReader @end -@implementation MachineApiCodecReader +@implementation AuthResponseApiCodecReader - (nullable id)readValueOfType:(UInt8)type { switch (type) { case 128: - return [Machine fromList:[self readValue]]; + return [AuthResponse fromList:[self readValue]]; default: return [super readValueOfType:type]; } } @end -@interface MachineApiCodecWriter : FlutterStandardWriter +@interface AuthResponseApiCodecWriter : FlutterStandardWriter @end -@implementation MachineApiCodecWriter +@implementation AuthResponseApiCodecWriter - (void)writeValue:(id)value { - if ([value isKindOfClass:[Machine class]]) { + if ([value isKindOfClass:[AuthResponse class]]) { [self writeByte:128]; [self writeValue:[value toList]]; } else { @@ -79,39 +99,43 @@ - (void)writeValue:(id)value { } @end -@interface MachineApiCodecReaderWriter : FlutterStandardReaderWriter +@interface AuthResponseApiCodecReaderWriter : FlutterStandardReaderWriter @end -@implementation MachineApiCodecReaderWriter +@implementation AuthResponseApiCodecReaderWriter - (FlutterStandardWriter *)writerWithData:(NSMutableData *)data { - return [[MachineApiCodecWriter alloc] initWithData:data]; + return [[AuthResponseApiCodecWriter alloc] initWithData:data]; } - (FlutterStandardReader *)readerWithData:(NSData *)data { - return [[MachineApiCodecReader alloc] initWithData:data]; + return [[AuthResponseApiCodecReader alloc] initWithData:data]; } @end -NSObject *MachineApiGetCodec(void) { +NSObject *AuthResponseApiGetCodec(void) { static FlutterStandardMessageCodec *sSharedObject = nil; static dispatch_once_t sPred = 0; dispatch_once(&sPred, ^{ - MachineApiCodecReaderWriter *readerWriter = [[MachineApiCodecReaderWriter alloc] init]; + AuthResponseApiCodecReaderWriter *readerWriter = [[AuthResponseApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void MachineApiSetup(id binaryMessenger, NSObject *api) { +void AuthResponseApiSetup(id binaryMessenger, NSObject *api) { { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.MachineApi.getMachineDetails" + initWithName:@"dev.flutter.pigeon.AuthResponseApi.login" binaryMessenger:binaryMessenger - codec:MachineApiGetCodec()]; + codec:AuthResponseApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(getMachineDetailsWithError:)], @"MachineApi api (%@) doesn't respond to @selector(getMachineDetailsWithError:)", api); + NSCAssert([api respondsToSelector:@selector(loginUsername:password:isConnected:error:)], @"AuthResponseApi api (%@) doesn't respond to @selector(loginUsername:password:isConnected:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + NSString *arg_username = GetNullableObjectAtIndex(args, 0); + NSString *arg_password = GetNullableObjectAtIndex(args, 1); + NSNumber *arg_isConnected = GetNullableObjectAtIndex(args, 2); FlutterError *error; - Machine *output = [api getMachineDetailsWithError:&error]; + AuthResponse *output = [api loginUsername:arg_username password:arg_password isConnected:arg_isConnected error:&error]; callback(wrapResult(output, error)); }]; } else { diff --git a/lib/platform_android/auth_impl.dart b/lib/platform_android/auth_impl.dart index aa85f0f49..08686d2ff 100644 --- a/lib/platform_android/auth_impl.dart +++ b/lib/platform_android/auth_impl.dart @@ -15,5 +15,19 @@ class AuthImpl extends Auth { print('User not fetched! ${e.toString()}'); } return user; + + } + + @override + Future logoutUser() async { + late User user; + try { + user = await UserApi().logoutUser(); + } on PlatformException { + print('UserApi logout call failed'); + } catch(e) { + print('User not fetched! ${e.toString()}'); + } + return user; } } \ No newline at end of file diff --git a/lib/platform_spi/auth.dart b/lib/platform_spi/auth.dart index aca00c17d..962656e56 100644 --- a/lib/platform_spi/auth.dart +++ b/lib/platform_spi/auth.dart @@ -2,4 +2,5 @@ import 'package:registration_client/pigeon/user_pigeon.dart'; abstract class Auth { Future validateUser(String username); -} \ No newline at end of file + Future logoutUser(); +} diff --git a/lib/provider/auth_provider.dart b/lib/provider/auth_provider.dart index c5550e6f4..b71f57cf7 100644 --- a/lib/provider/auth_provider.dart +++ b/lib/provider/auth_provider.dart @@ -1,4 +1,7 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:registration_client/pigeon/user_pigeon.dart'; import 'package:registration_client/platform_android/auth_impl.dart'; @@ -54,10 +57,20 @@ class AuthProvider with ChangeNotifier { notifyListeners(); } + clearUser() { + _isLoggedIn = false; + _isValidUser = false; + _isDefault = false; + _isOfficer = false; + _isOnboarded = false; + _isSupervisor = false; + notifyListeners(); + } + validateUser(username) async { final user = await AuthImpl().validateUser(username); - if(user.errorCode != null) { + if (user.errorCode != null) { _isValidUser = false; } else { _isOnboarded = false; @@ -67,4 +80,24 @@ class AuthProvider with ChangeNotifier { notifyListeners(); } -} \ No newline at end of file + + logoutUser() async { + User response; + User response_validate_user; + Map mp; + try { + //response = await OnboardingPage2View.platform.invokeMethod("logout"); + response = await AuthImpl().logoutUser(); + + // response_validate_user = await OnboardingPage2View.platform + // .invokeMethod("validateUsername", {'username': ""}); + response_validate_user = await AuthImpl().validateUser(""); + //mp = jsonDecode(response_validate_user); + print("usermap in auth_provider------------: $response_validate_user"); + } on PlatformException catch (e) { + //response = "Some Error Occurred"; + print("Some Error Occurred ${e}"); + } + notifyListeners(); + } +} diff --git a/lib/ui/onboard/home_page.dart b/lib/ui/onboard/home_page.dart index c1298be1b..466bb584c 100644 --- a/lib/ui/onboard/home_page.dart +++ b/lib/ui/onboard/home_page.dart @@ -9,7 +9,6 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; import 'package:registration_client/model/process.dart'; - import 'package:registration_client/provider/global_provider.dart'; import 'package:registration_client/ui/process_ui/widgets/new_process_language_selection.dart'; @@ -18,15 +17,24 @@ import 'package:registration_client/provider/registration_task_provider.dart'; import 'package:registration_client/utils/app_config.dart'; import 'package:responsive_grid_list/responsive_grid_list.dart'; +import '../../provider/auth_provider.dart'; +import '../../utils/app_style.dart'; +import '../login_page.dart'; import 'widgets/home_page_card.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -class HomePage extends StatelessWidget { +class HomePage extends StatefulWidget { static const route = "/home-page"; const HomePage({super.key}); static const platform = MethodChannel('com.flutter.dev/io.mosip.get-package-instance'); + @override + State createState() => _HomePageState(); +} + +class _HomePageState extends State { void syncData(BuildContext context) async { await _masterDataSync(); await _getNewProcessSpec(context); @@ -37,7 +45,7 @@ class HomePage extends StatelessWidget { Future _masterDataSync() async { String result; try { - result = await platform.invokeMethod("masterDataSync"); + result = await HomePage.platform.invokeMethod("masterDataSync"); } on PlatformException catch (e) { result = "Some Error Occurred: $e"; } @@ -59,7 +67,7 @@ class HomePage extends StatelessWidget { Future _getNewProcessSpec(BuildContext context) async { try { context.read().listOfProcesses = - await platform.invokeMethod("getNewProcessSpec"); + await HomePage.platform.invokeMethod("getNewProcessSpec"); await Clipboard.setData(ClipboardData( text: context .read() @@ -73,7 +81,7 @@ class HomePage extends StatelessWidget { Future _getUISchema() async { String result; try { - result = await platform.invokeMethod("getUISchema"); + result = await HomePage.platform.invokeMethod("getUISchema"); } on PlatformException catch (e) { result = "Some Error Occurred: $e"; } @@ -83,7 +91,7 @@ class HomePage extends StatelessWidget { Future getCenterName(BuildContext context) async { String result; try { - result = await platform.invokeMethod("getCenterName", + result = await HomePage.platform.invokeMethod("getCenterName", {"centerId": context.read().centerId}); } on PlatformException catch (e) { result = "Some Error Occurred: $e"; @@ -93,8 +101,15 @@ class HomePage extends StatelessWidget { return result; } + late AuthProvider authProvider; + @override Widget build(BuildContext context) { + authProvider = Provider.of(context, listen: false); + Future logout() async { + await context.read().logoutUser(); + } + double w = ScreenUtil().screenWidth; List> operationalTasks = [ { @@ -260,6 +275,48 @@ class HomePage extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ + InkWell( + //onTap: widget.onLogout, + onTap: () async { + print("logging out"); + authProvider.clearUser(); + await logout(); + print("logged out"); + + Navigator.popUntil( + context, ModalRoute.withName(HomePage.route)); + // Navigator.of(context).pushNamed(LoginPage.route); + // Navigator.pushNamed(context, LoginPage.route); + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => LoginPage()), + ); + print("Navigated to Login Page"); + }, + child: Container( + // width: 129.w, + height: 46.h, + padding: EdgeInsets.only( + left: 46.w, + right: 47.w, + ), + decoration: BoxDecoration( + border: Border.all( + width: 1.h, + color: AppStyle.appHelpText, + ), + borderRadius: const BorderRadius.all( + Radius.circular(5), + ), + ), + child: Center( + child: Text( + AppLocalizations.of(context)!.logout, + style: AppStyle.mobileHelpText, + ), + ), + ), + ), Text( "Operational Tasks", style: Theme.of(context) diff --git a/macos/Flutter/Flutter-Debug.xcconfig b/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b60..4b81f9b2d 100644 --- a/macos/Flutter/Flutter-Debug.xcconfig +++ b/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/Flutter-Release.xcconfig b/macos/Flutter/Flutter-Release.xcconfig index c2efd0b60..5caa9d157 100644 --- a/macos/Flutter/Flutter-Release.xcconfig +++ b/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Podfile b/macos/Podfile new file mode 100644 index 000000000..049abe295 --- /dev/null +++ b/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/pigeon.sh b/pigeon.sh index 85bb7c858..8a58e7f25 100644 --- a/pigeon.sh +++ b/pigeon.sh @@ -3,3 +3,6 @@ flutter pub run pigeon --input pigeon/user.dart --dart_out lib/pigeon/user_pigeo # Generate machine pigeon files flutter pub run pigeon --input pigeon/machine.dart --dart_out lib/pigeon/machine_pigeon.dart --objc_header_out ios/Runner/pigeon.h --objc_source_out ios/Runner/pigeon.m --java_out ./android/app/src/main/java/io/mosip/registration_client/model/MachinePigeon.java --java_package "io.mosip.registration_client.model" + +# Generate auth_response pigeon files +flutter pub run pigeon --input pigeon/auth_response.dart --dart_out lib/pigeon/auth_response_pigeon.dart --objc_header_out ios/Runner/pigeon.h --objc_source_out ios/Runner/pigeon.m --java_out ./android/app/src/main/java/io/mosip/registration_client/model/AuthResponsePigeon.java --java_package "io.mosip.registration_client.model" diff --git a/pigeon/auth_response.dart b/pigeon/auth_response.dart new file mode 100644 index 000000000..eadf03e75 --- /dev/null +++ b/pigeon/auth_response.dart @@ -0,0 +1,24 @@ +import 'package:pigeon/pigeon.dart'; + +class AuthResponse { + final String response; + final String username; + final bool isOfficer; + final bool isDefault; + final bool isSupervisor; + final String? errorCode; + + AuthResponse({ + required this.response, + required this.username, + required this.isOfficer, + required this.isDefault, + required this.isSupervisor, + this.errorCode, + }); +} + +@HostApi() +abstract class AuthResponseApi { + AuthResponse login(String username, String password, bool isConnected); +} \ No newline at end of file diff --git a/pigeon/user.dart b/pigeon/user.dart index 8b23dfe89..e120cd16f 100644 --- a/pigeon/user.dart +++ b/pigeon/user.dart @@ -32,5 +32,8 @@ class User { @HostApi() abstract class UserApi { + @async User validateUser(String username); + @async + User logoutUser(); }