refactor: Homeserver picker

This commit is contained in:
Krille Fear 2021-11-15 12:14:00 +01:00
commit 4bc45a75c5
3 changed files with 95 additions and 126 deletions

View file

@ -137,6 +137,17 @@ class HomeserverPickerController extends State<HomeserverPicker> {
.setItem(SettingKeys.jitsiInstance, jitsi);
AppConfig.jitsiInstance = jitsi;
}
_rawLoginTypes = await Matrix.of(context).getLoginClient().request(
RequestType.GET,
'/client/r0/login',
);
try {
await Matrix.of(context).getLoginClient().register();
registrationSupported = true;
} on MatrixException catch (e) {
registrationSupported = e.requireAdditionalAuthentication ?? false;
}
} catch (e) {
setState(() => error = (e as Object).toLocalizedString(context));
} finally {
@ -181,22 +192,6 @@ class HomeserverPickerController extends State<HomeserverPicker> {
.tryGetList('flows')
.any((flow) => flow['type'] == AuthenticationTypes.sso);
Future<Map<String, dynamic>> getLoginTypes() async {
_rawLoginTypes ??= await Matrix.of(context).getLoginClient().request(
RequestType.GET,
'/client/r0/login',
);
if (registrationSupported == null) {
try {
await Matrix.of(context).getLoginClient().register();
registrationSupported = true;
} on MatrixException catch (e) {
registrationSupported = e.requireAdditionalAuthentication ?? false;
}
}
return _rawLoginTypes;
}
ChromeSafariBrowser browser;
static const String ssoHomeserverKey = 'sso-homeserver';