Fix login fail on browser

This commit is contained in:
Inex Code 2020-10-14 23:07:36 +03:00
parent c1791edd4d
commit c175674cd8
1 changed files with 16 additions and 10 deletions

View File

@ -225,11 +225,14 @@ class Client extends MatrixApi {
var wellKnown = WellKnownInformations.fromJson(json.decode(response.body)); var wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
if (Uri.parse(wellKnown.mHomeserver.baseUrl).host != if (Uri.parse(wellKnown.mHomeserver.baseUrl).host !=
MatrixIdOrDomain.domain) { MatrixIdOrDomain.domain) {
final response = await http.get( try {
'https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client'); final response = await http.get(
if (response.statusCode == 200) { '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));
}
} catch (_) {}
} }
return wellKnown; return wellKnown;
} }
@ -241,11 +244,14 @@ class Client extends MatrixApi {
await http.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.get( try {
'https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client'); final response = await http.get(
if (response.statusCode == 200) { '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));
}
} catch (_) {}
} }
return wellKnown; return wellKnown;
} }