WT 1.1.5 ios: apple login - remove unnecessary fields

This commit is contained in:
bossanyit
2021-02-05 22:18:19 +01:00
parent ef2bd04a3a
commit 3c5360f224
13 changed files with 187 additions and 103 deletions
+34 -1
View File
@@ -19,6 +19,7 @@ import 'package:aitrainer_app/service/exercise_tree_service.dart';
import 'package:aitrainer_app/service/exercisetype_service.dart';
import 'package:aitrainer_app/service/firebase_api.dart';
import 'package:aitrainer_app/service/logging.dart';
import 'package:aitrainer_app/util/enums.dart';
import 'package:aitrainer_app/util/env.dart';
import 'package:flurry/flurry.dart';
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
@@ -63,6 +64,7 @@ class Cache with Logging {
static final String langKey = 'lang';
static final String serverKey = 'live';
static final String hardwareKey = 'hardware';
static final String loginTypeKey = 'login_type';
static String baseUrl = 'http://aitrainer.info:8888/api/';
static final String mediaUrl = 'https://aitrainer.info:4343/media/';
@@ -73,6 +75,7 @@ class Cache with Logging {
AccessToken accessTokenFacebook;
Customer userLoggedIn;
String firebaseUid;
LoginType loginType;
bool hasPurchased = false;
@@ -184,6 +187,24 @@ class Cache with Logging {
}
}
Future<void> setLoginTypeFromPrefs() async {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
SharedPreferences sharedPreferences = await prefs;
final String loginType = sharedPreferences.getString(Cache.loginTypeKey);
LoginType type = LoginType.email;
if (loginType == LoginType.apple.toString()) {
type = LoginType.apple;
} else if (loginType == LoginType.google.toString()) {
type = LoginType.google;
} else if (loginType == LoginType.fb.toString()) {
type = LoginType.fb;
} else if (loginType == LoginType.email.toString()) {
type = LoginType.email;
}
print("LoginType: " + loginType == null ? "NULL" : loginType);
Cache().setLoginType(type);
}
static String getToken(SharedPreferences prefs) {
return prefs.getString(authTokenKey);
}
@@ -201,6 +222,8 @@ class Cache with Logging {
userLoggedIn = customer;
final String uid = Cache().firebaseUid;
SharedPreferences sharedPreferences = await prefs;
sharedPreferences.setString(Cache.loginTypeKey, Cache().getLoginType().toString());
await setPreferences(prefs, SharePrefsChange.registration, customer.customerId, uid);
}
@@ -208,16 +231,22 @@ class Cache with Logging {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
userLoggedIn = customer;
SharedPreferences sharedPreferences = await prefs;
sharedPreferences.setString(Cache.loginTypeKey, Cache().getLoginType().toString());
await setPreferences(prefs, SharePrefsChange.login, customer.customerId, Cache().firebaseUid);
}
afterFirebaseLogin() async {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
SharedPreferences sharedPreferences = await prefs;
sharedPreferences.setString(Cache.loginTypeKey, Cache().getLoginType().toString());
await setPreferences(prefs, SharePrefsChange.login, userLoggedIn.customerId, Cache().firebaseUid);
}
afterFacebookLogin() async {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
SharedPreferences sharedPreferences = await prefs;
sharedPreferences.setString(Cache.loginTypeKey, Cache().getLoginType().toString());
await setPreferences(prefs, SharePrefsChange.login, userLoggedIn.customerId, Cache().firebaseUid);
}
@@ -392,7 +421,7 @@ class Cache with Logging {
_badges = LinkedHashMap();
customerRepository.setCustomer(userLoggedIn);
if (this.userLoggedIn != null) {
if (this.userLoggedIn.firstname == null || userLoggedIn.firstname.length == 0) {
if (this.userLoggedIn.birthYear == null || this.userLoggedIn.birthYear == 0) {
setBadge("personalData", true);
setBadge("account", true);
}
@@ -457,9 +486,13 @@ class Cache with Logging {
await customerRepository.getProductTests();
//this.hasPurchased = this._purchases.isNotEmpty;
await setLoginTypeFromPrefs();
Cache().startPage = "home";
}
AccessToken get getAccessTokenFacebook => accessTokenFacebook;
set setAccessTokenFacebook(AccessToken accessTokenFacebook) => this.accessTokenFacebook = accessTokenFacebook;
LoginType getLoginType() => loginType;
void setLoginType(LoginType type) => this.loginType = type;
}