Fix login fail if secondary well-known is invalid
This commit is contained in:
parent
6d60189df1
commit
c1791edd4d
|
@ -223,28 +223,33 @@ class Client extends MatrixApi {
|
||||||
final response = await http
|
final response = await http
|
||||||
.get('https://${MatrixIdOrDomain.domain}/.well-known/matrix/client');
|
.get('https://${MatrixIdOrDomain.domain}/.well-known/matrix/client');
|
||||||
var wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
var wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
||||||
if (Uri.parse(wellKnown.mHomeserver.baseUrl).host != MatrixIdOrDomain.domain) {
|
if (Uri.parse(wellKnown.mHomeserver.baseUrl).host !=
|
||||||
final response = await http
|
MatrixIdOrDomain.domain) {
|
||||||
.get('https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client');
|
final response = await http.get(
|
||||||
wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
'https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client');
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return wellKnown;
|
return wellKnown;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<WellKnownInformations> getWellKnownInformationsByDomain(dynamic serverUrl) async {
|
Future<WellKnownInformations> getWellKnownInformationsByDomain(
|
||||||
|
dynamic serverUrl) async {
|
||||||
var homeserver = (serverUrl is Uri) ? serverUrl : Uri.parse(serverUrl);
|
var homeserver = (serverUrl is Uri) ? serverUrl : Uri.parse(serverUrl);
|
||||||
final response = await http
|
final response =
|
||||||
.get('https://${homeserver.host}/.well-known/matrix/client');
|
await http.get('https://${homeserver.host}/.well-known/matrix/client');
|
||||||
var wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
var wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
||||||
if (Uri.parse(wellKnown.mHomeserver.baseUrl).host != homeserver.host) {
|
if (Uri.parse(wellKnown.mHomeserver.baseUrl).host != homeserver.host) {
|
||||||
final response = await http
|
final response = await http.get(
|
||||||
.get('https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client');
|
'https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client');
|
||||||
wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
if (response.statusCode == 200) {
|
||||||
}
|
wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
||||||
|
}
|
||||||
|
}
|
||||||
return wellKnown;
|
return wellKnown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Checks the supported versions of the Matrix protocol and the supported
|
/// Checks the supported versions of the Matrix protocol and the supported
|
||||||
/// login types. Returns false if the server is not compatible with the
|
/// login types. Returns false if the server is not compatible with the
|
||||||
/// client.
|
/// client.
|
||||||
|
|
Loading…
Reference in New Issue