refactor: Homeserver picker
This commit is contained in:
parent
205c4a7220
commit
4bc45a75c5
3 changed files with 95 additions and 126 deletions
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue