From 7f3240242d1b256f4fe854ad8e0fe3a188345f23 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Thu, 6 Mar 2025 20:21:59 +0100 Subject: [PATCH] remove google and facebook auth --- covas_mobile/android/gradle.properties | 1 + covas_mobile/lib/classes/auth_service.dart | 56 ---------------------- covas_mobile/lib/pages/LoginDemo.dart | 47 ------------------ 3 files changed, 1 insertion(+), 103 deletions(-) diff --git a/covas_mobile/android/gradle.properties b/covas_mobile/android/gradle.properties index 94adc3a..f489260 100644 --- a/covas_mobile/android/gradle.properties +++ b/covas_mobile/android/gradle.properties @@ -1,3 +1,4 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true +flutter.compileSdkVersion=35 \ No newline at end of file diff --git a/covas_mobile/lib/classes/auth_service.dart b/covas_mobile/lib/classes/auth_service.dart index f17bb1e..507c3e4 100644 --- a/covas_mobile/lib/classes/auth_service.dart +++ b/covas_mobile/lib/classes/auth_service.dart @@ -1,14 +1,10 @@ import 'dart:convert'; -import 'package:flutter_facebook_auth/flutter_facebook_auth.dart'; -import 'package:google_sign_in/google_sign_in.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:http/http.dart' as http; import '../variable/globals.dart' as globals; import 'dart:io'; class AuthService { - final GoogleSignIn _googleSignIn = GoogleSignIn(); - // Login with username and password Future login(String username, String password) async { final url = Uri.parse("${globals.api}/token"); @@ -53,7 +49,6 @@ class AuthService { Future logout() async { final prefs = await SharedPreferences.getInstance(); await prefs.remove("access_token"); - await _googleSignIn.signOut(); } Future isLoggedIn() async { @@ -97,56 +92,5 @@ class AuthService { return prefs.getString("access_token"); } - // Login with Facebook - Future signInWithFacebook() async { - try { - final LoginResult result = await FacebookAuth.instance.login(); - if (result.status == LoginStatus.success && result.accessToken != null) { - final AccessToken? accessToken = result.accessToken; - - final response = await http.post( - Uri.parse("${globals.api}/auth/facebook"), - headers: {"Content-Type": "application/json"}, - body: jsonEncode({"token": accessToken!.tokenString}), - ); - - if (response.statusCode == 200) { - final data = json.decode(response.body); - final prefs = await SharedPreferences.getInstance(); - prefs.setString("access_token", data["access_token"]); - return data["access_token"]; - } - } - } catch (e) { - print("Facebook login error: $e"); - } - return null; - } - // Login with Google - Future signInWithGoogle() async { - try { - final GoogleSignInAccount? googleUser = await _googleSignIn.signIn(); - if (googleUser == null) return null; // User canceled login - - final GoogleSignInAuthentication googleAuth = - await googleUser.authentication; - - final response = await http.post( - Uri.parse("${globals.api}/auth/google"), - headers: {"Content-Type": "application/json"}, - body: jsonEncode({"token": googleAuth.idToken}), - ); - - if (response.statusCode == 200) { - final data = json.decode(response.body); - final prefs = await SharedPreferences.getInstance(); - prefs.setString("access_token", data["access_token"]); - return data["access_token"]; - } - } catch (e) { - print("Google login error: $e"); - } - return null; - } } diff --git a/covas_mobile/lib/pages/LoginDemo.dart b/covas_mobile/lib/pages/LoginDemo.dart index 9700639..da04d52 100644 --- a/covas_mobile/lib/pages/LoginDemo.dart +++ b/covas_mobile/lib/pages/LoginDemo.dart @@ -39,26 +39,6 @@ class _LoginDemoState extends State with ShowAlertDialog { } } - Future _loginWithFacebook(BuildContext context) async { - String? token = await _authService.signInWithFacebook(); - if (token != null) { - Navigator.push( - context, MaterialPageRoute(builder: (_) => ListItemMenu())); - } else { - showAlertDialog(context, "Erreur", "Échec de la connexion Facebook"); - } - } - - Future _loginWithGoogle(BuildContext context) async { - String? token = await _authService.signInWithGoogle(); - if (token != null) { - Navigator.push( - context, MaterialPageRoute(builder: (_) => ListItemMenu())); - } else { - showAlertDialog(context, "Erreur", "Échec de la connexion Google"); - } - } - @override void initState() { super.initState(); @@ -149,33 +129,6 @@ class _LoginDemoState extends State with ShowAlertDialog { style: TextStyle(color: Colors.white, fontSize: 25)), ), ), - SizedBox(height: 20), - Container( - height: 50, - width: 250, - decoration: BoxDecoration( - color: Colors.blueAccent, - borderRadius: BorderRadius.circular(20)), - child: TextButton( - onPressed: () => _loginWithFacebook(context), - child: Text('Login with Facebook', - style: TextStyle(color: Colors.white, fontSize: 20)), - ), - ), - SizedBox(height: 20), - // Google Login Button - Container( - height: 50, - width: 250, - decoration: BoxDecoration( - color: Colors.redAccent, - borderRadius: BorderRadius.circular(20)), - child: TextButton( - onPressed: () => _loginWithGoogle(context), - child: Text('Login with Google', - style: TextStyle(color: Colors.white, fontSize: 20)), - ), - ), SizedBox(height: 130), InkWell( child: Text('New User? Create Account'),