This commit is contained in:
Hamza-Ayed
2024-05-27 13:21:14 +03:00
parent 3ff0eace3f
commit 6f3c8b975e
23 changed files with 213 additions and 171 deletions

View File

@@ -0,0 +1,35 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:get/get.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
class AuthController extends GetxController {
final FirebaseAuth _auth = FirebaseAuth.instance;
Future<User?> signInWithApple() async {
try {
final appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
);
final oAuthProvider = OAuthProvider('apple.com');
final credential = oAuthProvider.credential(
idToken: appleCredential.identityToken,
accessToken: appleCredential.authorizationCode,
);
UserCredential userCredential =
await _auth.signInWithCredential(credential);
return userCredential.user;
} catch (error) {
print("Error during Apple sign-in: $error");
return null;
}
}
void signOut() async {
await _auth.signOut();
}
}

View File

@@ -66,8 +66,9 @@ class LoginController extends GetxController {
if (jsonDecoeded['status'] == 'success' &&
jsonDecoeded['data'][0]['verified'] == 1) {
//
box.write(BoxName.isVerified, 'true');
box.write(BoxName.isVerified, '1');
box.write(BoxName.email, jsonDecoeded['data'][0]['email']);
box.write(BoxName.phone, jsonDecoeded['data'][0]['phone']);
print(box.read(BoxName.tokenFCM));
var token = await CRUD().get(link: AppLink.getTokens, payload: {
@@ -78,12 +79,14 @@ class LoginController extends GetxController {
if (token != 'failure') {
if (jsonDecode(token)['data'][0]['token'] !=
box.read(BoxName.tokenFCM)) {
print('token changed');
Get.put(FirebaseMessagesController())
.sendNotificationToAnyWithoutData(
'token change',
'change device',
jsonDecode(token)['data'][0]['token'].toString(),
);
Future.delayed(const Duration(seconds: 1));
await CRUD().post(link: AppLink.addTokens, payload: {
'token': box.read(BoxName.tokenFCM),
'passengerID': box.read(BoxName.passengerID).toString()

View File

@@ -116,7 +116,7 @@ class RegisterController extends GetxController {
payload: payload,
);
if (jsonDecode(res1)['status'] == 'success') {
box.write(BoxName.isVerified, 'true');
box.write(BoxName.isVerified, '1');
box.write(BoxName.phone, '+2${phoneController.text}');
Get.offAll(const MapPagePassenger());
}