Solian/lib/providers/content/realm.dart

22 lines
672 B
Dart
Raw Normal View History

2024-05-25 16:11:00 +00:00
import 'package:get/get.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/services.dart';
class RealmProvider extends GetxController {
Future<Response> listAvailableRealm() async {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) throw Exception('unauthorized');
2024-05-26 05:39:21 +00:00
final client = GetConnect(maxAuthRetries: 3);
2024-05-25 16:11:00 +00:00
client.httpClient.baseUrl = ServiceFinder.services['passport'];
client.httpClient.addAuthenticator(auth.requestAuthenticator);
2024-05-28 14:13:23 +00:00
final resp = await client.get('/api/realms/me/available');
2024-05-25 16:11:00 +00:00
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
return resp;
}
}