Update: 2026-06-12 20:40:40
This commit is contained in:
@@ -32,7 +32,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.siro.siro_service"
|
||||
minSdk = flutter.minSdkVersion
|
||||
minSdk = 30
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
<application
|
||||
android:name="${applicationName}"
|
||||
android:label="service"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:icon="@mipmap/launcher_icon">
|
||||
|
||||
<activity
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="false">
|
||||
<trust-anchors>
|
||||
<certificates src="system" />
|
||||
</trust-anchors>
|
||||
</base-config>
|
||||
|
||||
<domain-config cleartextTrafficPermitted="false">
|
||||
<domain includeSubdomains="true">intaleq.xyz</domain>
|
||||
<domain includeSubdomains="true">siromove.com</domain>
|
||||
|
||||
<pin-set expiration="2028-01-01">
|
||||
<!-- Primary: ISRG Root X1 (RSA) -->
|
||||
<pin digest="SHA-256">C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHESsl=</pin>
|
||||
<!-- Backup: ISRG Root X2 (ECDSA) -->
|
||||
<pin digest="SHA-256">diGVwiVYbubAI3RW4hB9xU8e/CH2GnkuvVFZE8zmgzI=</pin>
|
||||
</pin-set>
|
||||
</domain-config>
|
||||
</network-security-config>
|
||||
@@ -44,17 +44,14 @@ class RegisterController extends GetxController {
|
||||
if (res != 'failure' && res is Map && res['status'] == 'success') {
|
||||
// حفظ كلمة المرور للدخول التلقائي لاحقاً
|
||||
await storage.write(key: 'password', value: password.text);
|
||||
|
||||
Get.defaultDialog(
|
||||
|
||||
title: "نجاح",
|
||||
middleText: res['message']['message'] ?? "تم تقديم طلبك بنجاح. يرجى انتظار موافقة الإدارة.",
|
||||
onConfirm: () {
|
||||
Get.back(); // close dialog
|
||||
Get.back(); // return to login
|
||||
},
|
||||
textConfirm: "موافق",
|
||||
);
|
||||
// Request OTP
|
||||
bool otpSent = await _sendOtp(phone.text);
|
||||
if (otpSent) {
|
||||
_showOtpDialog(phone.text, res['message']?['message'] ?? "تم تقديم طلبك بنجاح. يرجى انتظار موافقة الإدارة.");
|
||||
} else {
|
||||
Get.snackbar('Error', 'Failed to send OTP'.tr);
|
||||
}
|
||||
} else {
|
||||
Get.snackbar(
|
||||
"خطأ",
|
||||
@@ -66,6 +63,86 @@ class RegisterController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> _sendOtp(String phoneNumber) async {
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link: '${AppLink.server}/auth/otp/request.php',
|
||||
payload: {
|
||||
'receiver': phoneNumber,
|
||||
'user_type': 'service'
|
||||
},
|
||||
);
|
||||
return response != 'failure';
|
||||
} catch (e) {
|
||||
Log.print('OTP SEND ERROR: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void _showOtpDialog(String phoneNumber, String successMessage) {
|
||||
String otpCode = '';
|
||||
Get.defaultDialog(
|
||||
title: 'رمز التحقق'.tr,
|
||||
content: Column(
|
||||
children: [
|
||||
Text('تم إرسال رمز التحقق إلى رقمك ($phoneNumber)'.tr),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
onChanged: (val) => otpCode = val,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'أدخل الرمز هنا'.tr,
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
textConfirm: 'تحقق'.tr,
|
||||
confirmTextColor: Colors.white,
|
||||
onConfirm: () async {
|
||||
if (otpCode.length >= 3) {
|
||||
Get.back(); // close dialog
|
||||
await _verifyOtpAndFinalize(phoneNumber, otpCode, successMessage);
|
||||
} else {
|
||||
Get.snackbar('خطأ', 'الرجاء إدخال رمز صحيح'.tr);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _verifyOtpAndFinalize(String phoneNumber, String otp, String successMessage) async {
|
||||
Get.dialog(const Center(child: CircularProgressIndicator()), barrierDismissible: false);
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link: '${AppLink.server}/auth/otp/verify.php',
|
||||
payload: {
|
||||
'phone_number': phoneNumber,
|
||||
'token_code': otp,
|
||||
'user_type': 'service',
|
||||
},
|
||||
);
|
||||
Get.back(); // close loading
|
||||
|
||||
if (response != 'failure' && response['status'] == 'success') {
|
||||
Get.defaultDialog(
|
||||
title: "نجاح".tr,
|
||||
middleText: successMessage,
|
||||
onConfirm: () {
|
||||
Get.back(); // close success dialog
|
||||
Get.back(); // return to login page
|
||||
},
|
||||
textConfirm: "موافق".tr,
|
||||
);
|
||||
} else {
|
||||
Get.snackbar('Error', 'Invalid OTP'.tr);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.back(); // close loading
|
||||
Log.print('OTP VERIFY ERROR: $e');
|
||||
Get.snackbar('Error', e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
firstName.dispose();
|
||||
|
||||
@@ -35,6 +35,7 @@ class LoginController extends GetxController {
|
||||
var payload = {
|
||||
"fingerprint": fingerprint,
|
||||
"password": pass,
|
||||
"email": email.text.trim(),
|
||||
"aud": "service",
|
||||
};
|
||||
|
||||
@@ -43,26 +44,16 @@ class LoginController extends GetxController {
|
||||
Log.print('📥 Login Response: $res');
|
||||
|
||||
if (res != 'failure' && res is Map && res['status'] == 'success') {
|
||||
var d = res[
|
||||
'message']; // V1 returns {status, message: {jwt, data: {user...}}}
|
||||
var d = res['message']; // V1 returns {status, message: {jwt, data: {user...}}}
|
||||
|
||||
// Store JWT & HMAC
|
||||
final jwt = d['jwt'];
|
||||
final hmac = d['hmac'];
|
||||
await box.write(BoxName.jwt, c(jwt));
|
||||
if (hmac != null) {
|
||||
await box.write(BoxName.hmac, hmac);
|
||||
// Request OTP from unified module
|
||||
String phone = d['data']['phone'] ?? '';
|
||||
bool otpSent = await _sendOtp(phone);
|
||||
if (otpSent) {
|
||||
_showOtpDialog(phone, pass, fingerprint, d);
|
||||
} else {
|
||||
Get.snackbar('Error', 'Failed to send OTP'.tr);
|
||||
}
|
||||
|
||||
// Store User Data
|
||||
var userData = d['data'];
|
||||
await storage.write(key: 'name', value: userData['first_name']);
|
||||
await storage.write(key: 'driverID', value: userData['id'].toString());
|
||||
await storage.write(key: 'password', value: pass);
|
||||
await box.write(BoxName.employeename, userData['first_name']);
|
||||
await box.write(BoxName.password, pass);
|
||||
|
||||
Get.offAll(() => Main());
|
||||
} else {
|
||||
Get.snackbar(
|
||||
'خطأ'.tr,
|
||||
@@ -73,6 +64,93 @@ class LoginController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> _sendOtp(String phone) async {
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link: '${AppLink.server}/auth/otp/request.php',
|
||||
payload: {
|
||||
'receiver': phone,
|
||||
'user_type': 'service'
|
||||
},
|
||||
);
|
||||
return response != 'failure';
|
||||
} catch (e) {
|
||||
Log.print('OTP SEND ERROR: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void _showOtpDialog(String phone, String pass, String fingerprint, dynamic loginData) {
|
||||
String otpCode = '';
|
||||
Get.defaultDialog(
|
||||
title: 'رمز التحقق'.tr,
|
||||
content: Column(
|
||||
children: [
|
||||
Text('تم إرسال رمز التحقق إلى رقمك ($phone)'.tr),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
onChanged: (val) => otpCode = val,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'أدخل الرمز هنا'.tr,
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
textConfirm: 'تحقق'.tr,
|
||||
confirmTextColor: Colors.white,
|
||||
onConfirm: () async {
|
||||
if (otpCode.length >= 3) {
|
||||
Get.back(); // close dialog
|
||||
await _verifyOtpAndFinalize(phone, otpCode, pass, loginData);
|
||||
} else {
|
||||
Get.snackbar('خطأ', 'الرجاء إدخال رمز صحيح'.tr);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _verifyOtpAndFinalize(String phone, String otp, String pass, dynamic loginData) async {
|
||||
Get.dialog(const Center(child: CircularProgressIndicator()), barrierDismissible: false);
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link: '${AppLink.server}/auth/otp/verify.php',
|
||||
payload: {
|
||||
'phone_number': phone,
|
||||
'token_code': otp,
|
||||
'user_type': 'service',
|
||||
},
|
||||
);
|
||||
Get.back(); // close loading
|
||||
|
||||
if (response != 'failure' && response['status'] == 'success') {
|
||||
// Finalize login
|
||||
final jwt = loginData['jwt'];
|
||||
final hmac = loginData['hmac'];
|
||||
await box.write(BoxName.jwt, c(jwt));
|
||||
if (hmac != null) {
|
||||
await box.write(BoxName.hmac, hmac);
|
||||
}
|
||||
|
||||
var userData = loginData['data'];
|
||||
await storage.write(key: 'name', value: userData['first_name']);
|
||||
await storage.write(key: 'driverID', value: userData['id'].toString());
|
||||
await storage.write(key: 'password', value: pass);
|
||||
await box.write(BoxName.employeename, userData['first_name']);
|
||||
await box.write(BoxName.password, pass);
|
||||
|
||||
Get.offAll(() => Main());
|
||||
} else {
|
||||
Get.snackbar('Error', 'Invalid OTP'.tr);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.back();
|
||||
Log.print('OTP VERIFY ERROR: $e');
|
||||
Get.snackbar('Error', e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
await EncryptionHelper.initialize();
|
||||
|
||||
Reference in New Issue
Block a user