Skip to content

Commit 67f313f

Browse files
committed
Added missing if
1 parent 5b254a1 commit 67f313f

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

lib/client.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class Client {
101101
}
102102

103103
Future<Response> call(HttpMethod method, {String path = '', Map<String, String> headers = const {}, Map<String, dynamic> params = const {}}) async {
104-
if(selfSigned) {
104+
if(selfSigned && !kIsWeb) {
105105
// Allow self signed requests
106106
(http.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) {
107107
client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;

lib/services/account.dart

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import 'dart:io';
3+
import 'package:universal_html/html.dart' as html;
34

45
import 'package:dio/dio.dart';
56
import 'package:meta/meta.dart';
@@ -337,19 +338,26 @@ class Account extends Service {
337338
query: query.join('&')
338339
);
339340

340-
return FlutterWebAuth.authenticate(
341-
url: url.toString(),
342-
callbackUrlScheme: "appwrite-callback-" + client.config['project']
343-
).then((value) async {
344-
Uri url = Uri.parse(value);
345-
Cookie cookie = new Cookie(url.queryParameters['key'], url.queryParameters['secret']);
346-
cookie.domain = Uri.parse(client.endPoint).host;
347-
cookie.httpOnly = true;
348-
cookie.path = '/';
349-
List<Cookie> cookies = [cookie];
350-
await client.init();
351-
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
352-
});
341+
if(kIsWeb) {
342+
html.window.location.href = url.toString();
343+
return null;
344+
}else{
345+
346+
return FlutterWebAuth.authenticate(
347+
url: url.toString(),
348+
callbackUrlScheme: "appwrite-callback-" + client.config['project']
349+
).then((value) async {
350+
Uri url = Uri.parse(value);
351+
Cookie cookie = new Cookie(url.queryParameters['key'], url.queryParameters['secret']);
352+
cookie.domain = Uri.parse(client.endPoint).host;
353+
cookie.httpOnly = true;
354+
cookie.path = '/';
355+
List<Cookie> cookies = [cookie];
356+
await client.init();
357+
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
358+
});
359+
}
360+
353361
}
354362

355363
/// Delete Account Session

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies:
1515
cookie_jar: ^1.0.1
1616
dio_cookie_manager: ^1.0.0
1717
flutter_web_auth: ^0.2.4
18+
universal_html: ^1.2.3
1819
flutter:
1920
sdk: flutter
2021

0 commit comments

Comments
 (0)