reAuthenticate method
ReAuthenticate rest and scketio clients
Implementation
Future<dynamic> reAuthenticate() async {
if (this.client == 'rest') {
return await standaloneRest!.reAuthenticate();
} else if (this.client == 'socketio') {
return await standaloneSocketio!.reAuthenticate();
}
// If no client is set, use the default one
try {
//Auth with rest to refresh or create accessToken
bool isRestAuthenticated = await rest.reAuthenticate();
try {
//Then auth with jwt socketio
bool isSocketioAuthenticated = await scketio.authWithJWT();
// Check wether both client are authenticated or not
if (isRestAuthenticated == true && isSocketioAuthenticated == true) {
return true;
} else {
// Both failed
throw new FeatherJsError(
type: FeatherJsErrorType.IS_AUTH_FAILED_ERROR,
error: "Auth failed with unknown reason");
}
} on FeatherJsError catch (e) {
// Socketio failed
throw new FeatherJsError(type: e.type, error: e);
}
} on FeatherJsError catch (e) {
// Rest failed
throw new FeatherJsError(type: e.type, error: e);
}
}