5/20/1
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:SEFER/controller/firebase/firbase_messge.dart';
|
||||
import 'package:SEFER/views/auth/register_page.dart';
|
||||
import 'package:SEFER/views/auth/sms_verfy_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -41,6 +44,65 @@ class LoginController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
loginFromSignInGoogle(String passengerID, email) async {
|
||||
isloading = true;
|
||||
update();
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.loginFromGooglePassenger, payload: {
|
||||
'email': email,
|
||||
'id': passengerID,
|
||||
});
|
||||
print(res);
|
||||
if (res == 'Failure') {
|
||||
//Failure
|
||||
Get.offAll(SmsSignupEgypt());
|
||||
isloading = false;
|
||||
update();
|
||||
Get.snackbar("User does not exist.".tr, '', backgroundColor: Colors.red);
|
||||
} else {
|
||||
var jsonDecoeded = jsonDecode(res);
|
||||
// print(jsonDecoeded['data'][0]['is_verified']);
|
||||
if (jsonDecoeded.isNotEmpty) {
|
||||
if (jsonDecoeded['status'] == 'success' &&
|
||||
jsonDecoeded['data'][0]['verified'] == 1) {
|
||||
//
|
||||
|
||||
Get.offAll(() => const MapPagePassenger());
|
||||
print(box.read(BoxName.tokenFCM));
|
||||
var token = await CRUD().get(link: AppLink.getTokens, payload: {
|
||||
'passengerID': box.read(BoxName.passengerID).toString()
|
||||
});
|
||||
print(token);
|
||||
if (token != 'failure') {
|
||||
if (jsonDecode(token)['data'][0]['token'] !=
|
||||
box.read(BoxName.tokenFCM)) {
|
||||
Get.find<FirebaseMessagesController>()
|
||||
.sendNotificationToAnyWithoutData(
|
||||
'token change',
|
||||
'change device',
|
||||
jsonDecode(token)['data'][0]['token'].toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
await CRUD().post(link: AppLink.addTokens, payload: {
|
||||
'token': box.read(BoxName.tokenFCM),
|
||||
'passengerID': box.read(BoxName.passengerID).toString()
|
||||
}).then((value) => print('cccc'));
|
||||
} else {
|
||||
Get.offAll(() => SmsSignupEgypt());
|
||||
// Get.snackbar(jsonDecoeded['status'], jsonDecoeded['data'],
|
||||
// backgroundColor: Colors.redAccent);
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
} else {
|
||||
print('res is null');
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void adminDashboardOpen() async {
|
||||
// if (formKeyAdmin.currentState!.validate()) {
|
||||
// await DeviceInfoPlus.getDeviceInfo();
|
||||
|
||||
Reference in New Issue
Block a user