Errorhandling Token problems
This commit is contained in:
@@ -28,7 +28,7 @@ namespace Jugenddienst_Stunden.Models {
|
||||
//public List<int>? timetable;
|
||||
|
||||
|
||||
|
||||
public event EventHandler<string> AlertEvent;
|
||||
|
||||
public static async Task<Operator> LoadData(string apiKey) {
|
||||
//var apiKey = Preferences.Default.Get("apiKey", "");
|
||||
@@ -41,12 +41,25 @@ namespace Jugenddienst_Stunden.Models {
|
||||
//throw new Exception("Keine Internetverbindung");
|
||||
} else {
|
||||
var tokendata = new TokenData(apiKey);
|
||||
string data = await Auth.GetApiDataWithAuthAsync(tokendata.url, tokendata.apiKey);
|
||||
if (data != null) {
|
||||
OperatorVar = Newtonsoft.Json.JsonConvert.DeserializeObject<Operator>(data);
|
||||
Preferences.Default.Set("name", OperatorVar.name);
|
||||
Preferences.Default.Set("surname", OperatorVar.surname);
|
||||
}
|
||||
//try {
|
||||
string data = await Auth.GetApiDataWithAuthAsync(tokendata.url, tokendata.apiKey);
|
||||
if (data == "\"Lalala\"") {
|
||||
throw new Exception("Problem mit Token");
|
||||
}
|
||||
if (data != null) {
|
||||
OperatorVar = Newtonsoft.Json.JsonConvert.DeserializeObject<Operator>(data);
|
||||
Preferences.Default.Set("name", OperatorVar.name);
|
||||
Preferences.Default.Set("surname", OperatorVar.surname);
|
||||
}
|
||||
//} catch (Exception e) {
|
||||
// //AlertEvent?.Invoke(this, e.Message);
|
||||
// await App.Current.MainPage.DisplayAlert("Fehler",
|
||||
// e.Message,
|
||||
// "OK");
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return OperatorVar;
|
||||
|
||||
Reference in New Issue
Block a user