Update: 2026-06-12 22:40:40
This commit is contained in:
@@ -25,6 +25,7 @@ import 'package:location/location.dart';
|
||||
import '../../env/env.dart';
|
||||
import '../../print.dart';
|
||||
import '../../views/auth/otp_token_page.dart';
|
||||
import '../functions/country_logic.dart';
|
||||
import '../functions/encrypt_decrypt.dart';
|
||||
import '../functions/package_info.dart';
|
||||
|
||||
@@ -48,7 +49,8 @@ class LoginController extends GetxController {
|
||||
@override
|
||||
void onInit() async {
|
||||
// Log.print('box.read(BoxName.isTest): ${box.read(BoxName.isTest)}');
|
||||
box.write(BoxName.countryCode, 'Syria');
|
||||
// كشف الدولة تلقائياً عبر الموقع الجغرافي
|
||||
await CountryLogic.initializeCountry();
|
||||
FirebaseMessagesController().getToken();
|
||||
super.onInit();
|
||||
}
|
||||
@@ -271,8 +273,6 @@ class LoginController extends GetxController {
|
||||
final res = await CRUD().get(
|
||||
link: AppLink.loginFromGooglePassenger,
|
||||
payload: {
|
||||
'email': email,
|
||||
'id': passengerID, // استخدم المعامل مباشرة
|
||||
'platform': Platform.isAndroid ? 'android' : 'ios',
|
||||
'appName': AppInformation.appName,
|
||||
},
|
||||
@@ -385,7 +385,7 @@ class LoginController extends GetxController {
|
||||
"inviteCode": invite,
|
||||
"passengerID": passengerID,
|
||||
});
|
||||
|
||||
|
||||
// سجل الدعوة أيضاً في النظام الموحد الجديد
|
||||
await CRUD().post(link: AppLink.addUnifiedInvite, payload: {
|
||||
"inviter_code": invite,
|
||||
@@ -445,46 +445,48 @@ class LoginController extends GetxController {
|
||||
// );
|
||||
// }
|
||||
|
||||
void login() async {
|
||||
void loginTester() async {
|
||||
isloading = true;
|
||||
update();
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.loginFromGooglePassenger, payload: {
|
||||
'email': (emailController.text),
|
||||
'id': passwordController.text,
|
||||
"platform": Platform.isAndroid ? 'android' : 'ios',
|
||||
"appName": AppInformation.appName,
|
||||
});
|
||||
|
||||
try {
|
||||
var fingerPrint = await DeviceHelper.getDeviceFingerprint();
|
||||
var payload = {
|
||||
'email': emailController.text.trim(),
|
||||
'password': passwordController.text.trim(),
|
||||
'fingerPrint': fingerPrint,
|
||||
'aud': '${AK.allowed}${Platform.isAndroid ? 'android' : 'ios'}',
|
||||
};
|
||||
|
||||
var response = await http.post(
|
||||
Uri.parse(AppLink.loginUsingCredentialsWithoutGooglePassenger),
|
||||
body: payload,
|
||||
);
|
||||
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
var jsonDecoeded = jsonDecode(response.body);
|
||||
if (jsonDecoeded['status'] == 'success' && jsonDecoeded['data'][0]['verified'].toString() == '1') {
|
||||
var d = jsonDecoeded['data'][0];
|
||||
var jwt = jsonDecoeded['jwt'];
|
||||
|
||||
// حفظ التوكن
|
||||
if (jwt != null) {
|
||||
box.write(BoxName.jwt, c(jwt));
|
||||
await storage.write(key: BoxName.jwt, value: c(jwt));
|
||||
}
|
||||
|
||||
isloading = false;
|
||||
update();
|
||||
if (res == 'Failure') {
|
||||
//Failure
|
||||
Get.offAll(() => LoginPage());
|
||||
isloading = false;
|
||||
update();
|
||||
// Get.snackbar("User does not exist.".tr, '', backgroundColor: Colors.red);
|
||||
} else {
|
||||
var jsonDecoeded = jsonDecode(res);
|
||||
if (jsonDecoeded.isNotEmpty) {
|
||||
if (jsonDecoeded['status'] == 'success' &&
|
||||
jsonDecoeded['data'][0]['verified'].toString() == '1') {
|
||||
//
|
||||
box.write(BoxName.isVerified, '1');
|
||||
box.write(BoxName.email, jsonDecoeded['data'][0]['email']);
|
||||
box.write(BoxName.name, jsonDecoeded['data'][0]['first_name']);
|
||||
box.write(BoxName.phone, jsonDecoeded['data'][0]['phone']);
|
||||
box.write(BoxName.passengerID, passwordController.text);
|
||||
// var token = await CRUD().get(link: AppLink.getTokens, payload: {
|
||||
// 'passengerID': box.read(BoxName.passengerID).toString()
|
||||
// });
|
||||
// await updateAppTester(AppInformation.appName);
|
||||
box.write(BoxName.email, d['email']);
|
||||
box.write(BoxName.name, d['first_name']);
|
||||
box.write(BoxName.phone, d['phone']);
|
||||
box.write(BoxName.passengerID, d['id']);
|
||||
box.write(BoxName.isTest, '1');
|
||||
|
||||
await storage.write(key: BoxName.fingerPrint, value: fingerPrint);
|
||||
|
||||
Get.offAll(() => const MapPagePassenger());
|
||||
} else {
|
||||
// Get.offAll(() => SmsSignupEgypt());
|
||||
// Get.snackbar(jsonDecoeded['status'], jsonDecoeded['data'],
|
||||
// backgroundColor: Colors.redAccent);
|
||||
Get.offAll(() => LoginPage());
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
@@ -492,6 +494,10 @@ class LoginController extends GetxController {
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
} catch (e) {
|
||||
Log.print("Tester Login Error: $e");
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user