diff --git a/Sources/justMUSIC/lib/exceptions/user_exception.dart b/Sources/justMUSIC/lib/exceptions/user_exception.dart new file mode 100644 index 0000000..22a137a --- /dev/null +++ b/Sources/justMUSIC/lib/exceptions/user_exception.dart @@ -0,0 +1,6 @@ +class UserException implements Exception { + String code; + String description; + + UserException(this.code,this.description); +} \ No newline at end of file diff --git a/Sources/justMUSIC/lib/model/Post.dart b/Sources/justMUSIC/lib/model/Post.dart index 224d956..66c3b53 100644 --- a/Sources/justMUSIC/lib/model/Post.dart +++ b/Sources/justMUSIC/lib/model/Post.dart @@ -9,13 +9,13 @@ class Post { String? _description; late Music _music; Tuple2 _location; - int _nblikes; + List _likes; String? _selfie; DateTime _date; // Constructor Post(this._id, this._user, this._description, this._location, - this._nblikes, this._selfie, this._date); + this._likes, this._selfie, this._date); //Getters and setters String get id => _id; @@ -40,10 +40,10 @@ class Post { _location = value; } - int get nblikes => _nblikes; + List get likes => _likes; - set nblikes(int value) { - _nblikes = value; + set likes(List value) { + _likes = value; } String? get selfie => _selfie; diff --git a/Sources/justMUSIC/lib/model/mapper/PostMapper.dart b/Sources/justMUSIC/lib/model/mapper/PostMapper.dart index 61ed7c4..f846568 100644 --- a/Sources/justMUSIC/lib/model/mapper/PostMapper.dart +++ b/Sources/justMUSIC/lib/model/mapper/PostMapper.dart @@ -15,7 +15,7 @@ class PostMapper { user!, data?["description"], Tuple2(data?["place"][0], data?["place"][1]), - data?["likes"], + List.from(data?["likes"] as List), data?["selfie"], data?["date"].toDate()); } diff --git a/Sources/justMUSIC/lib/screens/login_screen.dart b/Sources/justMUSIC/lib/screens/login_screen.dart index 10d3be2..eb44ba8 100644 --- a/Sources/justMUSIC/lib/screens/login_screen.dart +++ b/Sources/justMUSIC/lib/screens/login_screen.dart @@ -9,6 +9,7 @@ import 'package:justmusic/main.dart'; import 'package:justmusic/values/constants.dart'; import '../components/login_button.dart'; +import '../exceptions/user_exception.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({Key? key}) : super(key: key); @@ -46,6 +47,18 @@ class _LoginScreenState extends State { } } + signInWithGoogle() async { + try { + await MyApp.userViewModel.signInWithGoogle(); + } on UserException catch (e) { + if (e.code == 'user-created') { + Navigator.pushNamed(context, '/explanation'); + } else if (e.code == 'user-already-exist') { + Navigator.pushNamed(context, '/feed'); + } + } + } + @override Widget build(BuildContext context) { return GestureDetector( @@ -370,7 +383,7 @@ class _LoginScreenState extends State { SignInButton( Buttons.Google, text: "Login with Google", - onPressed: () {}, + onPressed: signInWithGoogle, ), ], ), diff --git a/Sources/justMUSIC/lib/screens/profile_screen.dart b/Sources/justMUSIC/lib/screens/profile_screen.dart index 54cf845..d68a3ae 100644 --- a/Sources/justMUSIC/lib/screens/profile_screen.dart +++ b/Sources/justMUSIC/lib/screens/profile_screen.dart @@ -1,4 +1,3 @@ -import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -21,8 +20,7 @@ class _ProfileScreenState extends State { @override Widget build(BuildContext context) { Future logout() async { - print("cc"); - await FirebaseAuth.instance.signOut(); + await MyApp.userViewModel.logout(); Navigator.pushNamed(context, '/welcome'); } diff --git a/Sources/justMUSIC/lib/screens/registration_screen.dart b/Sources/justMUSIC/lib/screens/registration_screen.dart index 9d03be5..d18543d 100644 --- a/Sources/justMUSIC/lib/screens/registration_screen.dart +++ b/Sources/justMUSIC/lib/screens/registration_screen.dart @@ -7,6 +7,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_signin_button/button_list.dart'; import 'package:flutter_signin_button/button_view.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:justmusic/exceptions/user_exception.dart'; import 'package:justmusic/values/constants.dart'; import '../components/login_button.dart'; @@ -46,6 +47,18 @@ class _RegistrationScreenState extends State { } } + signInWithGoogle() async { + try { + await MyApp.userViewModel.signInWithGoogle(); + } on UserException catch (e) { + if (e.code == 'user-created') { + Navigator.pushNamed(context, '/explanation'); + } else if (e.code == 'user-already-exist') { + Navigator.pushNamed(context, '/feed'); + } + } + } + @override Widget build(BuildContext context) { return Scaffold( @@ -63,8 +76,10 @@ class _RegistrationScreenState extends State { padding: EdgeInsets.only(top: 100.h), child: AutoSizeText( "On a besoin de ça!", - style: - GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w600, fontSize: 30.w), + style: GoogleFonts.plusJakartaSans( + color: Colors.white, + fontWeight: FontWeight.w600, + fontSize: 30.w), maxLines: 1, maxFontSize: 50, overflow: TextOverflow.fade, @@ -76,7 +91,8 @@ class _RegistrationScreenState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( - padding: EdgeInsets.symmetric(horizontal: defaultPadding), + padding: EdgeInsets.symmetric( + horizontal: defaultPadding), child: Padding( padding: EdgeInsets.only(bottom: 50.h), child: Column( @@ -90,7 +106,9 @@ class _RegistrationScreenState extends State { child: AutoSizeText( "Promis c’est rapide.", style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontWeight: FontWeight.w400, fontSize: 17.w), + color: Colors.white, + fontWeight: FontWeight.w400, + fontSize: 17.w), maxFontSize: 20, textAlign: TextAlign.center, ), @@ -100,7 +118,10 @@ class _RegistrationScreenState extends State { ), ), Padding( - padding: EdgeInsets.only(bottom: 16.h, left: defaultPadding, right: defaultPadding), + padding: EdgeInsets.only( + bottom: 16.h, + left: defaultPadding, + right: defaultPadding), child: TextFormField( controller: _userPseudoTextField, keyboardAppearance: Brightness.dark, @@ -112,24 +133,37 @@ class _RegistrationScreenState extends State { }, cursorColor: primaryColor, keyboardType: TextInputType.emailAddress, - style: GoogleFonts.plusJakartaSans(color: primaryColor, fontSize: 15), + style: GoogleFonts.plusJakartaSans( + color: primaryColor, fontSize: 15), decoration: InputDecoration( focusedBorder: OutlineInputBorder( - borderSide: BorderSide(width: 1.sp, color: strokeTextField), - borderRadius: const BorderRadius.all(Radius.circular(10))), - prefix: const Padding(padding: EdgeInsets.only(left: 20.0)), - suffix: const Padding(padding: EdgeInsets.only(left: 20.0)), + borderSide: BorderSide( + width: 1.sp, + color: strokeTextField), + borderRadius: const BorderRadius.all( + Radius.circular(10))), + prefix: const Padding( + padding: EdgeInsets.only(left: 20.0)), + suffix: const Padding( + padding: EdgeInsets.only(left: 20.0)), fillColor: bgTextField, filled: true, - focusColor: const Color.fromRGBO(255, 255, 255, 0.30), + focusColor: const Color.fromRGBO( + 255, 255, 255, 0.30), enabledBorder: const OutlineInputBorder( - borderSide: BorderSide(width: 1, color: strokeTextField), - borderRadius: BorderRadius.all(Radius.circular(10))), + borderSide: BorderSide( + width: 1, color: strokeTextField), + borderRadius: BorderRadius.all( + Radius.circular(10))), hintText: 'Pseudo', - hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField)), + hintStyle: GoogleFonts.plusJakartaSans( + color: strokeTextField)), )), Padding( - padding: EdgeInsets.only(bottom: 16.h, left: defaultPadding, right: defaultPadding), + padding: EdgeInsets.only( + bottom: 16.h, + left: defaultPadding, + right: defaultPadding), child: TextFormField( controller: _userMailTextField, keyboardAppearance: Brightness.dark, @@ -141,24 +175,36 @@ class _RegistrationScreenState extends State { }, cursorColor: primaryColor, keyboardType: TextInputType.emailAddress, - style: GoogleFonts.plusJakartaSans(color: primaryColor), + style: GoogleFonts.plusJakartaSans( + color: primaryColor), decoration: InputDecoration( focusedBorder: OutlineInputBorder( - borderSide: BorderSide(width: 1, color: strokeTextField), - borderRadius: BorderRadius.all(Radius.circular(10))), - prefix: const Padding(padding: EdgeInsets.only(left: 20.0)), - suffix: const Padding(padding: EdgeInsets.only(left: 20.0)), + borderSide: BorderSide( + width: 1, color: strokeTextField), + borderRadius: BorderRadius.all( + Radius.circular(10))), + prefix: const Padding( + padding: EdgeInsets.only(left: 20.0)), + suffix: const Padding( + padding: EdgeInsets.only(left: 20.0)), fillColor: bgTextField, filled: true, - focusColor: Color.fromRGBO(255, 255, 255, 0.30), + focusColor: + Color.fromRGBO(255, 255, 255, 0.30), enabledBorder: OutlineInputBorder( - borderSide: BorderSide(width: 1, color: strokeTextField), - borderRadius: BorderRadius.all(Radius.circular(10))), + borderSide: BorderSide( + width: 1, color: strokeTextField), + borderRadius: BorderRadius.all( + Radius.circular(10))), hintText: 'Email', - hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField)), + hintStyle: GoogleFonts.plusJakartaSans( + color: strokeTextField)), )), Padding( - padding: EdgeInsets.only(bottom: 16.h, left: defaultPadding, right: defaultPadding), + padding: EdgeInsets.only( + bottom: 16.h, + left: defaultPadding, + right: defaultPadding), child: TextFormField( controller: _passwordTextField, keyboardAppearance: Brightness.dark, @@ -170,21 +216,29 @@ class _RegistrationScreenState extends State { return null; }, cursorColor: primaryColor, - style: GoogleFonts.plusJakartaSans(color: primaryColor), + style: GoogleFonts.plusJakartaSans( + color: primaryColor), decoration: InputDecoration( focusedBorder: OutlineInputBorder( - borderSide: BorderSide(width: 1, color: strokeTextField), - borderRadius: BorderRadius.all(Radius.circular(10))), - prefix: const Padding(padding: EdgeInsets.only(left: 20.0)), - suffix: const Padding(padding: EdgeInsets.only(left: 20.0)), + borderSide: BorderSide( + width: 1, color: strokeTextField), + borderRadius: + BorderRadius.all(Radius.circular(10))), + prefix: const Padding( + padding: EdgeInsets.only(left: 20.0)), + suffix: const Padding( + padding: EdgeInsets.only(left: 20.0)), fillColor: bgTextField, filled: true, focusColor: Color.fromRGBO(255, 255, 255, 0.30), enabledBorder: OutlineInputBorder( - borderSide: BorderSide(width: 1, color: strokeTextField), - borderRadius: BorderRadius.all(Radius.circular(10))), + borderSide: BorderSide( + width: 1, color: strokeTextField), + borderRadius: + BorderRadius.all(Radius.circular(10))), hintText: 'Mot de passe', - hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField), + hintStyle: GoogleFonts.plusJakartaSans( + color: strokeTextField), suffixIcon: Container( padding: EdgeInsets.only(right: 10), margin: EdgeInsets.all(5), @@ -204,8 +258,10 @@ class _RegistrationScreenState extends State { // Splash color over image child: Image( image: passenable - ? AssetImage("assets/images/show_icon.png") - : AssetImage("assets/images/hide_icon.png"), + ? AssetImage( + "assets/images/show_icon.png") + : AssetImage( + "assets/images/hide_icon.png"), height: 2, ), )), @@ -213,7 +269,10 @@ class _RegistrationScreenState extends State { ), ), Padding( - padding: EdgeInsets.only(bottom: 16.h, left: defaultPadding, right: defaultPadding), + padding: EdgeInsets.only( + bottom: 16.h, + left: defaultPadding, + right: defaultPadding), child: TextFormField( controller: _passwordConfirmTextField, keyboardAppearance: Brightness.dark, @@ -228,21 +287,29 @@ class _RegistrationScreenState extends State { }, cursorColor: primaryColor, keyboardType: TextInputType.emailAddress, - style: GoogleFonts.plusJakartaSans(color: primaryColor), + style: GoogleFonts.plusJakartaSans( + color: primaryColor), decoration: InputDecoration( focusedBorder: OutlineInputBorder( - borderSide: BorderSide(width: 1, color: strokeTextField), - borderRadius: BorderRadius.all(Radius.circular(10))), - prefix: const Padding(padding: EdgeInsets.only(left: 20.0)), - suffix: const Padding(padding: EdgeInsets.only(left: 20.0)), + borderSide: BorderSide( + width: 1, color: strokeTextField), + borderRadius: + BorderRadius.all(Radius.circular(10))), + prefix: const Padding( + padding: EdgeInsets.only(left: 20.0)), + suffix: const Padding( + padding: EdgeInsets.only(left: 20.0)), fillColor: bgTextField, filled: true, focusColor: Color.fromRGBO(255, 255, 255, 0.30), enabledBorder: OutlineInputBorder( - borderSide: BorderSide(width: 1, color: strokeTextField), - borderRadius: BorderRadius.all(Radius.circular(10))), + borderSide: BorderSide( + width: 1, color: strokeTextField), + borderRadius: + BorderRadius.all(Radius.circular(10))), hintText: 'Confirmation du Mot de passe', - hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField), + hintStyle: GoogleFonts.plusJakartaSans( + color: strokeTextField), suffixIcon: Container( padding: EdgeInsets.only(right: 10), margin: EdgeInsets.all(5), @@ -262,8 +329,10 @@ class _RegistrationScreenState extends State { // Splash color over image child: Image( image: passenable - ? AssetImage("assets/images/show_icon.png") - : AssetImage("assets/images/hide_icon.png"), + ? AssetImage( + "assets/images/show_icon.png") + : AssetImage( + "assets/images/hide_icon.png"), height: 2, ), )), @@ -271,7 +340,8 @@ class _RegistrationScreenState extends State { ), ), Padding( - padding: EdgeInsets.symmetric(horizontal: defaultPadding), + padding: EdgeInsets.symmetric( + horizontal: defaultPadding), child: SizedBox( width: 600, child: LoginButton( @@ -292,12 +362,16 @@ class _RegistrationScreenState extends State { text: TextSpan( text: 'Tu as déjà un compte?', style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontWeight: FontWeight.w400, fontSize: 15), + color: Colors.white, + fontWeight: FontWeight.w400, + fontSize: 15), children: [ TextSpan( text: " Connexion", style: GoogleFonts.plusJakartaSans( - fontSize: 15, fontWeight: FontWeight.w400, color: primaryColor)), + fontSize: 15, + fontWeight: FontWeight.w400, + color: primaryColor)), ], ), ), @@ -319,10 +393,13 @@ class _RegistrationScreenState extends State { ), ), Padding( - padding: const EdgeInsets.only(left: defaultPadding, right: defaultPadding), + padding: const EdgeInsets.only( + left: defaultPadding, right: defaultPadding), child: Text( 'Ou', - style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.bold), + style: GoogleFonts.plusJakartaSans( + color: Colors.white, + fontWeight: FontWeight.bold), ), ), Expanded( @@ -342,8 +419,10 @@ class _RegistrationScreenState extends State { child: SignInButton( Buttons.Google, text: "Login with Google", - onPressed: () {}, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))), + onPressed: signInWithGoogle, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(20))), ), ), ), @@ -354,10 +433,13 @@ class _RegistrationScreenState extends State { child: Container( height: 240.h, decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topRight, - stops: [0, 1], - colors: [bgColor.withOpacity(1), bgColor.withOpacity(0)])), + gradient: LinearGradient(begin: Alignment.topRight, stops: [ + 0, + 1 + ], colors: [ + bgColor.withOpacity(1), + bgColor.withOpacity(0) + ])), ), ), Align( @@ -365,7 +447,8 @@ class _RegistrationScreenState extends State { child: ConstrainedBox( constraints: BoxConstraints(maxWidth: 800), child: Padding( - padding: EdgeInsets.only(top: 45.h, left: defaultPadding, right: defaultPadding), + padding: EdgeInsets.only( + top: 45.h, left: defaultPadding, right: defaultPadding), child: ClipRRect( borderRadius: BorderRadius.circular(10.0), child: LinearProgressIndicator( diff --git a/Sources/justMUSIC/lib/services/AuthService.dart b/Sources/justMUSIC/lib/services/AuthService.dart index c11be8e..f4a1fdd 100644 --- a/Sources/justMUSIC/lib/services/AuthService.dart +++ b/Sources/justMUSIC/lib/services/AuthService.dart @@ -2,44 +2,53 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/foundation.dart'; +import 'package:google_sign_in/google_sign_in.dart'; +import 'package:justmusic/exceptions/user_exception.dart'; import '../main.dart'; class AuthService { - register(String pseudo, String email, String password) async { + Future addUserToFirestore( + UserCredential userCredential, String pseudo, String email) async { + var token; + if (!kIsWeb) { + token = await FirebaseMessaging.instance.getToken(); + } else { + token = "empty"; + } + + String uniqueId = await generateUniqueId(pseudo); + + final user = { + "mail": email, + "pseudo": pseudo, + "unique_id": uniqueId, + "followed": [], + "nbCapsules": 0, + "followers": [], + "token_notify": token, + "musics_likes": [], + "picture": + "https://firebasestorage.googleapis.com/v0/b/justmusic-435d5.appspot.com/o/justMusicDefaultImage.png?alt=media&token=020d0fcb-b7df-4d4d-b380-e99597293fcc" + }; + + try { + await MyApp.db + .collection("users") + .doc(userCredential.user?.uid) + .set(user); + print("User Added"); + } catch (error) { + print("Failed to add user: $error"); + } + } + + Future register(String pseudo, String email, String password) async { try { - var token; final data = await FirebaseAuth.instance.createUserWithEmailAndPassword( email: email, password: password, ); - - if (kIsWeb) { - token = "empty"; - } else { - token = await FirebaseMessaging.instance.getToken(); - } - - String uniqueId = await generateUniqueId(pseudo); - - final user = { - "mail": email, - "pseudo": pseudo, - "unique_id": uniqueId, - "followed": [], - "nbCapsules": 0, - "followers": [], - "token_notify": token, - "saved_musics": [], - "picture": - "https://firebasestorage.googleapis.com/v0/b/justmusic-435d5.appspot.com/o/justMusicDefaultImage.png?alt=media&token=020d0fcb-b7df-4d4d-b380-e99597293fcc" - }; - - MyApp.db - .collection("users") - .doc(data.user?.uid) - .set(user) - .then((value) => print("User Added")) - .catchError((error) => print("Failed to add user: $error")); + await addUserToFirestore(data, pseudo, email); } on FirebaseAuthException catch (e) { if (e.code == 'weak-password') { throw ('Mot de passe trop court'); @@ -52,11 +61,37 @@ class AuthService { } } + signInWithGoogle() async { + final GoogleSignInAccount? gUser = await GoogleSignIn().signIn(); + final GoogleSignInAuthentication gAuth = await gUser!.authentication; + final credential = GoogleAuthProvider.credential( + accessToken: gAuth.accessToken, + idToken: gAuth.idToken, + ); + + final userCredential = + await FirebaseAuth.instance.signInWithCredential(credential); + final user = + await MyApp.db.collection("users").doc(userCredential.user?.uid).get(); + + if (!user.exists) { + await addUserToFirestore( + userCredential, + userCredential.user?.displayName?.toLowerCase().replaceAll(' ', '') ?? "user", + userCredential.user?.email ?? ""); + throw UserException("user-created", "L'utilisateur vien d'être créé"); + } + + throw UserException("user-already-exist", "L'utilisateur existe déjà"); + } + Future generateUniqueId(String pseudo) async { String uniqueId = '$pseudo#0001'; int suffix = 1; - final CollectionReference usersCollection = FirebaseFirestore.instance.collection("users"); - final QuerySnapshot querySnapshot = await usersCollection.where('pseudo', isEqualTo: pseudo).get(); + final CollectionReference usersCollection = + FirebaseFirestore.instance.collection("users"); + final QuerySnapshot querySnapshot = + await usersCollection.where('pseudo', isEqualTo: pseudo).get(); querySnapshot.docs.forEach((snapshot) { suffix++; @@ -68,7 +103,8 @@ class AuthService { login(String email, String password) async { try { - await FirebaseAuth.instance.signInWithEmailAndPassword(email: email, password: password); + await FirebaseAuth.instance + .signInWithEmailAndPassword(email: email, password: password); } on FirebaseAuthException catch (e) { if (e.code == 'user-not-found') { throw ('Mail incorrect'); @@ -83,8 +119,14 @@ class AuthService { } } - void signOut() async { + signOut() async { await FirebaseAuth.instance.signOut(); + if (!kIsWeb) { + final GoogleSignIn googleSignIn = GoogleSignIn(); + if (await googleSignIn.isSignedIn()) { + await googleSignIn.signOut(); + } + } } Future delete() async { @@ -95,7 +137,8 @@ class AuthService { .doc(currentUser?.uid) .delete() .then((value) => print("Firestore deleted user")) - .catchError((error) => print("Error deleting user from Firestore: $error")); + .catchError( + (error) => print("Error deleting user from Firestore: $error")); await currentUser?.delete(); await FirebaseAuth.instance.signOut(); diff --git a/Sources/justMUSIC/lib/services/PostService.dart b/Sources/justMUSIC/lib/services/PostService.dart index 3eb1819..a7d9742 100644 --- a/Sources/justMUSIC/lib/services/PostService.dart +++ b/Sources/justMUSIC/lib/services/PostService.dart @@ -16,7 +16,7 @@ class PostService { "date": DateTime.now(), "place": [location?.item1, location?.item2], "song_id": idMusic, - "likes": 0 + "likes": [] }; var postAdd = await MyApp.db.collection("posts").add(post); diff --git a/Sources/justMUSIC/lib/view_model/UserViewModel.dart b/Sources/justMUSIC/lib/view_model/UserViewModel.dart index 62bd83b..8bff593 100644 --- a/Sources/justMUSIC/lib/view_model/UserViewModel.dart +++ b/Sources/justMUSIC/lib/view_model/UserViewModel.dart @@ -12,7 +12,7 @@ import '../main.dart'; class UserViewModel { late User _userCurrent; - final AuthService authService = AuthService(); + final AuthService _authService = AuthService(); final UserService _userService = UserService(); User get userCurrent => _userCurrent; @@ -34,7 +34,7 @@ class UserViewModel { login(String pseudo, String password) async { try { var token; - await authService.login(pseudo, password); + await _authService.login(pseudo, password); if (firebase_auth.FirebaseAuth.instance.currentUser!.emailVerified) { await updateUserCurrent(); if (!kIsWeb) { @@ -73,13 +73,23 @@ class UserViewModel { } try { - await authService.register(pseudo.toLowerCase(), email, password); + await _authService.register(pseudo.toLowerCase(), email, password); await updateUserCurrent(); } catch (e) { rethrow; } } + signInWithGoogle() async { + try { + await _authService.signInWithGoogle(); + await updateUserCurrent(); + } catch (e) { + print(e); + rethrow; + } + } + Future> getUsersByUniqueId(String uniqueId) async { try { var response = await _userService.getUsersByIdUnique(uniqueId.toLowerCase()); @@ -101,12 +111,12 @@ class UserViewModel { } } - logout() { - authService.signOut(); + logout() async { + await _authService.signOut(); } - delete() { - authService.delete(); + delete() async { + await _authService.delete(); } bool isFriend(String id) { diff --git a/Sources/justMUSIC/pubspec.lock b/Sources/justMUSIC/pubspec.lock index ef6e363..89568be 100644 --- a/Sources/justMUSIC/pubspec.lock +++ b/Sources/justMUSIC/pubspec.lock @@ -608,6 +608,54 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.4" + google_identity_services_web: + dependency: transitive + description: + name: google_identity_services_web + sha256: "7940fdc3b1035db4d65d387c1bdd6f9574deaa6777411569c05ecc25672efacd" + url: "https://pub.dev" + source: hosted + version: "0.2.1" + google_sign_in: + dependency: "direct main" + description: + name: google_sign_in + sha256: aab6fdc41374014494f9e9026b9859e7309639d50a0bf4a2a412467a5ae4abc6 + url: "https://pub.dev" + source: hosted + version: "6.1.4" + google_sign_in_android: + dependency: transitive + description: + name: google_sign_in_android + sha256: "8d60a787b29cb7d2bcf29230865f4a91f17323c6ac5b6b9027a6418e48d9ffc3" + url: "https://pub.dev" + source: hosted + version: "6.1.18" + google_sign_in_ios: + dependency: transitive + description: + name: google_sign_in_ios + sha256: "6ec0e13a4c5c646471b9f6a25ceb3ae76d339889d4c0f79b729bf0714215a63e" + url: "https://pub.dev" + source: hosted + version: "5.6.2" + google_sign_in_platform_interface: + dependency: transitive + description: + name: google_sign_in_platform_interface + sha256: e69553c0fc6a76216e9d06a8c3767e291ad9be42171f879aab7ab708569d4393 + url: "https://pub.dev" + source: hosted + version: "2.4.1" + google_sign_in_web: + dependency: transitive + description: + name: google_sign_in_web + sha256: "69b9ce0e760945ff52337921a8b5871592b74c92f85e7632293310701eea68cc" + url: "https://pub.dev" + source: hosted + version: "0.12.0+2" gradiantbutton: dependency: "direct main" description: @@ -904,6 +952,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.7.3" + quiver: + dependency: transitive + description: + name: quiver + sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 + url: "https://pub.dev" + source: hosted + version: "3.2.1" rxdart: dependency: transitive description: diff --git a/Sources/justMUSIC/pubspec.yaml b/Sources/justMUSIC/pubspec.yaml index 872339f..494ee35 100644 --- a/Sources/justMUSIC/pubspec.yaml +++ b/Sources/justMUSIC/pubspec.yaml @@ -75,6 +75,7 @@ dependencies: timezone: ^0.9.2 firebase_messaging: ^14.6.5 cached_network_image: ^3.2.3 + google_sign_in: ^6.1.4 dev_dependencies: flutter_test: