feat: submit user login with app
This commit is contained in:
@@ -10,4 +10,6 @@ abstract class AuthRemoteDataSource {
|
||||
Future<bool> hasAuthenticated();
|
||||
|
||||
Future<UserInfoModel?> getUserInfo(String phoneNumber);
|
||||
|
||||
Future<void> submitUserInfo(Map<String, dynamic> userInfo);
|
||||
}
|
||||
|
||||
@@ -47,4 +47,13 @@ class AuthRemoteDataSourceImp extends AuthRemoteDataSource {
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> submitUserInfo(Map<String, dynamic> userInfo)async {
|
||||
var res = await _httpClient.post(
|
||||
'/steward-app-login/',
|
||||
data: userInfo,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,7 @@ abstract class AuthRepository {
|
||||
Future<bool> hasAuthenticated();
|
||||
|
||||
Future<UserInfoModel?> getUserInfo(String phoneNumber);
|
||||
|
||||
Future<void> submitUserInfo({required String phone,String? deviceName});
|
||||
|
||||
}
|
||||
|
||||
@@ -22,4 +22,10 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
@override
|
||||
Future<UserInfoModel?> getUserInfo(String phoneNumber) async =>
|
||||
await authRemote.getUserInfo(phoneNumber);
|
||||
|
||||
@override
|
||||
Future<void> submitUserInfo({required String phone, String? deviceName}) async {
|
||||
var tmp = {'mobile': phone, 'device_name': deviceName};
|
||||
await authRemote.submitUserInfo(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/common/dio_error_handler.dart';
|
||||
@@ -42,6 +43,7 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
Rx<AuthType> authType = AuthType.useAndPass.obs;
|
||||
Rx<AuthStatus> authStatus = AuthStatus.init.obs;
|
||||
Rx<OtpStatus> otpStatus = OtpStatus.init.obs;
|
||||
RxnString deviceName = RxnString(null);
|
||||
|
||||
RxInt secondsRemaining = 120.obs;
|
||||
Timer? _timer;
|
||||
@@ -62,6 +64,7 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
textAnimation = CurvedAnimation(parent: _textAnimationController, curve: Curves.easeInOut);
|
||||
|
||||
initUserPassData();
|
||||
getDeviceModel();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -128,6 +131,11 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
);
|
||||
}
|
||||
|
||||
authRepository.submitUserInfo(
|
||||
phone: usernameController.value.text,
|
||||
deviceName: deviceName.value,
|
||||
);
|
||||
|
||||
if (tmpRoles!.length > 1) {
|
||||
Get.offAndToNamed(ChickenRoutes.role);
|
||||
} else {
|
||||
@@ -176,4 +184,24 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
rememberMe.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getDeviceModel() async {
|
||||
final deviceInfo = DeviceInfoPlugin();
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
final info = await deviceInfo.androidInfo;
|
||||
print('Device: ${info.manufacturer} ${info.model}');
|
||||
print('Android version: ${info.version.release}');
|
||||
deviceName.value =
|
||||
'Device:${info.manufacturer} Model:${info.model} version ${info.version.release}';
|
||||
} else if (Platform.isIOS) {
|
||||
final info = await deviceInfo.iosInfo;
|
||||
print('Device: ${info.utsname.machine} (${info.name})');
|
||||
print('System version: ${info.systemVersion}');
|
||||
deviceName.value =
|
||||
'Device:${info.utsname.machine} Model:${info.model} version ${info.systemVersion}';
|
||||
} else {
|
||||
print('Unsupported platform');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user