fix webuntis auth retry not working correctly
This commit is contained in:
@@ -19,7 +19,7 @@ abstract class WebuntisApi extends ApiRequest {
|
||||
WebuntisApi(this.method, this.genericParam, {this.authenticatedResponse = true});
|
||||
|
||||
|
||||
Future<String> query(WebuntisApi untis) async {
|
||||
Future<String> query(WebuntisApi untis, {bool retry = false}) async {
|
||||
var query = '{"id":"ID","method":"$method","params":${untis._body()},"jsonrpc":"2.0"}';
|
||||
|
||||
var sessionId = '0';
|
||||
@@ -32,8 +32,9 @@ abstract class WebuntisApi extends ApiRequest {
|
||||
dynamic jsonData = jsonDecode(data.body);
|
||||
if(jsonData['error'] != null) {
|
||||
if(jsonData['error']['code'] == -8520) {
|
||||
if(retry) throw WebuntisError('Authentication was tried (probably session timeout), but was not successful!', 1);
|
||||
await Authenticate.createSession();
|
||||
this.query(untis);
|
||||
return await this.query(untis, retry: true);
|
||||
} else {
|
||||
throw WebuntisError(jsonData['error']['message'], jsonData['error']['code']);
|
||||
}
|
||||
|
Reference in New Issue
Block a user