Skip to content

Commit 7df3de3

Browse files
committed
check for null and throw exception
1 parent 1e2f229 commit 7df3de3

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

templates/flutter/lib/src/client_io.dart.twig

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,16 @@ class ClientIO extends ClientBase with ClientMixin {
187187

188188
Future webAuth(Uri url) {
189189
return FlutterWebAuth.authenticate(
190-
url: url.toString(),
191-
callbackUrlScheme: "appwrite-callback-" + config['project']!)
192-
.then((value) async {
193-
Cookie cookie = new Cookie(
194-
url.queryParameters['key']!, url.queryParameters['secret']!);
190+
url: url.toString(),
191+
callbackUrlScheme: "appwrite-callback-" + config['project']!,
192+
).then((value) async {
193+
final key = url.queryParameters['key'];
194+
final secret = url.queryParameters['secret'];
195+
if (key == null || secret == null) {
196+
throw {{spec.title | caseUcfirst}}Exception(
197+
"Invalid OAuth2 Response. Key and Secret not available.", 500);
198+
}
199+
Cookie cookie = new Cookie(key, secret);
195200
cookie.domain = Uri.parse(_endPoint).host;
196201
cookie.httpOnly = true;
197202
cookie.path = '/';

0 commit comments

Comments
 (0)