parent
881d281136
commit
2c11b6f44a
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "994903990520",
|
||||||
|
"project_id": "justmusic-435d5",
|
||||||
|
"storage_bucket": "justmusic-435d5.appspot.com"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:994903990520:android:02a445b6561bf2820a9b0d",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.example.justmusic"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "994903990520-rdk6ldrmbi71ddqt84qfhtuficm7ngon.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyCjkofl0nvfzQqRZPv_-H99WoyYa7O660g"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "994903990520-9jsnq9ipdn7smk7tlbdd20i7j6sl3jcd.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_id": "994903990520-n6jd98ena56kb1tvtrd67tvb5et3nfbf.apps.googleusercontent.com",
|
||||||
|
"client_type": 2,
|
||||||
|
"ios_info": {
|
||||||
|
"bundle_id": "com.example.justmusic"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CLIENT_ID</key>
|
||||||
|
<string>994903990520-n6jd98ena56kb1tvtrd67tvb5et3nfbf.apps.googleusercontent.com</string>
|
||||||
|
<key>REVERSED_CLIENT_ID</key>
|
||||||
|
<string>com.googleusercontent.apps.994903990520-n6jd98ena56kb1tvtrd67tvb5et3nfbf</string>
|
||||||
|
<key>API_KEY</key>
|
||||||
|
<string>AIzaSyBbYqsR6t7JTi8_XFNEHd43IRuKlYGeI3U</string>
|
||||||
|
<key>GCM_SENDER_ID</key>
|
||||||
|
<string>994903990520</string>
|
||||||
|
<key>PLIST_VERSION</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>BUNDLE_ID</key>
|
||||||
|
<string>com.example.justmusic</string>
|
||||||
|
<key>PROJECT_ID</key>
|
||||||
|
<string>justmusic-435d5</string>
|
||||||
|
<key>STORAGE_BUCKET</key>
|
||||||
|
<string>justmusic-435d5.appspot.com</string>
|
||||||
|
<key>IS_ADS_ENABLED</key>
|
||||||
|
<false></false>
|
||||||
|
<key>IS_ANALYTICS_ENABLED</key>
|
||||||
|
<false></false>
|
||||||
|
<key>IS_APPINVITE_ENABLED</key>
|
||||||
|
<true></true>
|
||||||
|
<key>IS_GCM_ENABLED</key>
|
||||||
|
<true></true>
|
||||||
|
<key>IS_SIGNIN_ENABLED</key>
|
||||||
|
<true></true>
|
||||||
|
<key>GOOGLE_APP_ID</key>
|
||||||
|
<string>1:994903990520:ios:93188f32e320babe0a9b0d</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"file_generated_by": "FlutterFire CLI",
|
||||||
|
"purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
|
||||||
|
"GOOGLE_APP_ID": "1:994903990520:ios:93188f32e320babe0a9b0d",
|
||||||
|
"FIREBASE_PROJECT_ID": "justmusic-435d5",
|
||||||
|
"GCM_SENDER_ID": "994903990520"
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
// File generated by FlutterFire CLI.
|
||||||
|
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
|
||||||
|
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
|
||||||
|
import 'package:flutter/foundation.dart'
|
||||||
|
show defaultTargetPlatform, kIsWeb, TargetPlatform;
|
||||||
|
|
||||||
|
/// Default [FirebaseOptions] for use with your Firebase apps.
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// ```dart
|
||||||
|
/// import 'firebase_options.dart';
|
||||||
|
/// // ...
|
||||||
|
/// await Firebase.initializeApp(
|
||||||
|
/// options: DefaultFirebaseOptions.currentPlatform,
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
class DefaultFirebaseOptions {
|
||||||
|
static FirebaseOptions get currentPlatform {
|
||||||
|
if (kIsWeb) {
|
||||||
|
return web;
|
||||||
|
}
|
||||||
|
switch (defaultTargetPlatform) {
|
||||||
|
case TargetPlatform.android:
|
||||||
|
return android;
|
||||||
|
case TargetPlatform.iOS:
|
||||||
|
return ios;
|
||||||
|
case TargetPlatform.macOS:
|
||||||
|
throw UnsupportedError(
|
||||||
|
'DefaultFirebaseOptions have not been configured for macos - '
|
||||||
|
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||||
|
);
|
||||||
|
case TargetPlatform.windows:
|
||||||
|
throw UnsupportedError(
|
||||||
|
'DefaultFirebaseOptions have not been configured for windows - '
|
||||||
|
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||||
|
);
|
||||||
|
case TargetPlatform.linux:
|
||||||
|
throw UnsupportedError(
|
||||||
|
'DefaultFirebaseOptions have not been configured for linux - '
|
||||||
|
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
throw UnsupportedError(
|
||||||
|
'DefaultFirebaseOptions are not supported for this platform.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const FirebaseOptions web = FirebaseOptions(
|
||||||
|
apiKey: 'AIzaSyBv-Sba07nFFhctn6c3ARyvi9RfYwEKoNA',
|
||||||
|
appId: '1:994903990520:web:724c75003432ddbc0a9b0d',
|
||||||
|
messagingSenderId: '994903990520',
|
||||||
|
projectId: 'justmusic-435d5',
|
||||||
|
authDomain: 'justmusic-435d5.firebaseapp.com',
|
||||||
|
storageBucket: 'justmusic-435d5.appspot.com',
|
||||||
|
measurementId: 'G-D4YRLXK9TQ',
|
||||||
|
);
|
||||||
|
|
||||||
|
static const FirebaseOptions android = FirebaseOptions(
|
||||||
|
apiKey: 'AIzaSyCjkofl0nvfzQqRZPv_-H99WoyYa7O660g',
|
||||||
|
appId: '1:994903990520:android:02a445b6561bf2820a9b0d',
|
||||||
|
messagingSenderId: '994903990520',
|
||||||
|
projectId: 'justmusic-435d5',
|
||||||
|
storageBucket: 'justmusic-435d5.appspot.com',
|
||||||
|
);
|
||||||
|
|
||||||
|
static const FirebaseOptions ios = FirebaseOptions(
|
||||||
|
apiKey: 'AIzaSyBbYqsR6t7JTi8_XFNEHd43IRuKlYGeI3U',
|
||||||
|
appId: '1:994903990520:ios:93188f32e320babe0a9b0d',
|
||||||
|
messagingSenderId: '994903990520',
|
||||||
|
projectId: 'justmusic-435d5',
|
||||||
|
storageBucket: 'justmusic-435d5.appspot.com',
|
||||||
|
iosClientId: '994903990520-n6jd98ena56kb1tvtrd67tvb5et3nfbf.apps.googleusercontent.com',
|
||||||
|
iosBundleId: 'com.example.justmusic',
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:justmusic/model/User.dart';
|
||||||
|
import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;
|
||||||
|
import '../../main.dart';
|
||||||
|
|
||||||
|
class UserMapper {
|
||||||
|
static User? toModel(DocumentSnapshot<Map<String, dynamic>>? snapshot,
|
||||||
|
SnapshotOptions? options) {
|
||||||
|
if (snapshot == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final data = snapshot.data();
|
||||||
|
return User(
|
||||||
|
data?["uid"],
|
||||||
|
data?["pseudo"],
|
||||||
|
data?["country"],
|
||||||
|
data?["mail"],
|
||||||
|
data?["profilePicture"],
|
||||||
|
data?["followers"] as int,
|
||||||
|
data?["nbCapsules"] as int,
|
||||||
|
data?["followed"] as int,
|
||||||
|
data?['friends'] is Iterable ? List.from(data?['friends']) : []);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
static Map<String, dynamic> toFirebase(User user) {
|
||||||
|
return {
|
||||||
|
if (user.pseudo != null) "name": u,
|
||||||
|
if (user.country != null) "state": state,
|
||||||
|
if (user.mail != null) "country": country,
|
||||||
|
if (user.pp != null) "capital": capital,
|
||||||
|
if (user.followers != null) "population": population,
|
||||||
|
if (user.capsules != null) "regions": regions,
|
||||||
|
if ()
|
||||||
|
};
|
||||||
|
}*/
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,57 @@
|
|||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
|
import '../model/User.dart';
|
||||||
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
import '../main.dart';
|
||||||
|
|
||||||
|
class AuthService {
|
||||||
|
register(String pseudo, String email, String password) async {
|
||||||
|
try {
|
||||||
|
final data = await FirebaseAuth.instance.createUserWithEmailAndPassword(
|
||||||
|
email: email,
|
||||||
|
password: password,
|
||||||
|
);
|
||||||
|
|
||||||
|
final user = <String, dynamic>{
|
||||||
|
"mail": email,
|
||||||
|
"pseudo": pseudo,
|
||||||
|
"phone_number": "",
|
||||||
|
"picture":
|
||||||
|
"https://media.licdn.com/dms/image/D4E03AQHvc_b89ogFtQ/profile-displayphoto-shrink_400_400/0/1665060931103?e=1695859200&v=beta&t=wVLbxqeokYiPJ13nJ3SMq97iZvcm3ra0ufWFZCSzhjg",
|
||||||
|
"friends": []
|
||||||
|
};
|
||||||
|
|
||||||
|
MyApp.db
|
||||||
|
.collection("users")
|
||||||
|
.doc(data.user?.uid)
|
||||||
|
.set(user)
|
||||||
|
.then((value) => print("User Added"))
|
||||||
|
.catchError((error) => print("Failed to add user: $error"));
|
||||||
|
} on FirebaseAuthException catch (e) {
|
||||||
|
if (e.code == 'weak-password') {
|
||||||
|
throw ('The password provided is too weak.');
|
||||||
|
} else if (e.code == 'email-already-in-use') {
|
||||||
|
throw ('The account already exists for that email.');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw (e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
login(String email, String password) async {
|
||||||
|
try {
|
||||||
|
await FirebaseAuth.instance
|
||||||
|
.signInWithEmailAndPassword(email: email, password: password);
|
||||||
|
} on FirebaseAuthException catch (e) {
|
||||||
|
if (e.code == 'user-not-found') {
|
||||||
|
throw ('No user found for that email.');
|
||||||
|
} else if (e.code == 'wrong-password') {
|
||||||
|
throw ('Wrong password provided for that user.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void signOut() async {
|
||||||
|
await FirebaseAuth.instance.signOut();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
|
import '../model/User.dart';
|
||||||
|
import '../main.dart';
|
||||||
|
|
||||||
|
class UserService {
|
||||||
|
acceptFriend(User user, String idFriend) {
|
||||||
|
MyApp.db.collection("users").doc(user.id).update({
|
||||||
|
"friends": FieldValue.arrayUnion([idFriend])
|
||||||
|
});
|
||||||
|
MyApp.db.collection("users").doc(idFriend).update({
|
||||||
|
"friends": FieldValue.arrayUnion([user.id])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue