closes #2
This commit is contained in:
parent
16e81cc7ef
commit
4321fbafaa
|
|
@ -49,8 +49,36 @@ class DataManager{
|
||||||
await GetSettings();
|
await GetSettings();
|
||||||
await GetGames();
|
await GetGames();
|
||||||
await GetChallenges();
|
await GetChallenges();
|
||||||
|
await GetUserData();
|
||||||
CalculateEarnings();
|
CalculateEarnings();
|
||||||
}
|
}
|
||||||
|
static String username= "";
|
||||||
|
static String password = "";
|
||||||
|
|
||||||
|
static Future<int> GetUserData() async{
|
||||||
|
var loginResponse = null;
|
||||||
|
try {
|
||||||
|
loginResponse = (await http.post(
|
||||||
|
Uri.parse('${DataManager.API_ENDPOINT}get_userdata.php'),
|
||||||
|
body: <String, String>{
|
||||||
|
"username": username,
|
||||||
|
"password": password
|
||||||
|
}));
|
||||||
|
Debug.LogError(loginResponse.body.toString());
|
||||||
|
|
||||||
|
try{
|
||||||
|
DataManager.UserJson = jsonDecode(loginResponse.body.toString());
|
||||||
|
await DataManager.GetGamesProgress();
|
||||||
|
return 0;
|
||||||
|
}catch(e){
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
Debug.LogError("Error while login $e");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static Future<void> GetGamesProgress() async{
|
static Future<void> GetGamesProgress() async{
|
||||||
FilterLinkedGames();
|
FilterLinkedGames();
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,8 @@ class LoginManager {
|
||||||
Debug.LogResponse(DataManager.UserJson);
|
Debug.LogResponse(DataManager.UserJson);
|
||||||
prefs.setString("username", username);
|
prefs.setString("username", username);
|
||||||
prefs.setString("password", password);
|
prefs.setString("password", password);
|
||||||
|
DataManager.username = username;
|
||||||
|
DataManager.password = password;
|
||||||
return 0;
|
return 0;
|
||||||
}catch(e){
|
}catch(e){
|
||||||
return 5;
|
return 5;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user