WT1.1.3 logo change, error fixes
This commit is contained in:
@@ -47,7 +47,7 @@ class CustomerApi with Logging {
|
||||
throw new Exception(jsonDecode(responseBody)['error']);
|
||||
} else {
|
||||
customer = Customer.fromJson(jsonDecode(responseBody));
|
||||
Cache().afterRegistration(customer);
|
||||
await Cache().afterRegistration(customer);
|
||||
}
|
||||
} on FormatException {
|
||||
throw new Exception(responseBody);
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
//import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
|
||||
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
|
||||
|
||||
class FirebaseApi with Logging {
|
||||
static FirebaseApi _instance;
|
||||
@@ -75,16 +75,41 @@ class FirebaseApi with Logging {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*Future<UserCredential> signInWithFacebook() async {
|
||||
// Trigger the sign-in flow
|
||||
final LoginResult result = await FacebookAuth.instance.login();
|
||||
Future<Map<String, dynamic>> signInWithFacebook() async {
|
||||
Map<String, dynamic> userData;
|
||||
try {
|
||||
// by default the login method has the next permissions ['email','public_profile']
|
||||
AccessToken accessToken = await FacebookAuth.instance.login();
|
||||
if (accessToken != null) {
|
||||
log(accessToken.toJson().toString());
|
||||
Cache().accessTokenFacebook = accessToken;
|
||||
// get the user data
|
||||
userData = await FacebookAuth.instance.getUserData();
|
||||
Cache().facebookUid = userData['id'];
|
||||
log(userData.toString());
|
||||
} else {
|
||||
throw Exception("Facebook login was not successful");
|
||||
}
|
||||
} on FacebookAuthException catch (e) {
|
||||
switch (e.errorCode) {
|
||||
case FacebookAuthErrorCode.OPERATION_IN_PROGRESS:
|
||||
throw Exception("You have a previous Facebook login operation in progress");
|
||||
break;
|
||||
case FacebookAuthErrorCode.CANCELLED:
|
||||
throw Exception("Facebook login cancelled");
|
||||
break;
|
||||
case FacebookAuthErrorCode.FAILED:
|
||||
throw Exception("Facebook login failed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return userData;
|
||||
}
|
||||
|
||||
// Create a credential from the access token
|
||||
final FacebookAuthCredential facebookAuthCredential = FacebookAuthProvider.credential(result.accessToken.token);
|
||||
|
||||
// Once signed in, return the UserCredential
|
||||
return await FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);
|
||||
}*/
|
||||
Future<void> logOutFacebook() async {
|
||||
await FacebookAuth.instance.logOut();
|
||||
Cache().accessTokenFacebook = null;
|
||||
}
|
||||
|
||||
Future<void> signOut() async {
|
||||
await FirebaseAuth.instance.signOut();
|
||||
|
||||
Reference in New Issue
Block a user