Commit ab54357e authored by Leon Tappe's avatar Leon Tappe 🔥
Browse files

add proper check for valid qr code to prevent 500s

parent d02a76b2
...@@ -14,7 +14,7 @@ PODS: ...@@ -14,7 +14,7 @@ PODS:
- Reachability (3.2) - Reachability (3.2)
- shared_preferences_ios (0.0.1): - shared_preferences_ios (0.0.1):
- Flutter - Flutter
- url_launcher (0.0.1): - url_launcher_ios (0.0.1):
- Flutter - Flutter
DEPENDENCIES: DEPENDENCIES:
...@@ -24,7 +24,7 @@ DEPENDENCIES: ...@@ -24,7 +24,7 @@ DEPENDENCIES:
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
- qr_code_scanner (from `.symlinks/plugins/qr_code_scanner/ios`) - qr_code_scanner (from `.symlinks/plugins/qr_code_scanner/ios`)
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`) - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
SPEC REPOS: SPEC REPOS:
trunk: trunk:
...@@ -44,8 +44,8 @@ EXTERNAL SOURCES: ...@@ -44,8 +44,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/qr_code_scanner/ios" :path: ".symlinks/plugins/qr_code_scanner/ios"
shared_preferences_ios: shared_preferences_ios:
:path: ".symlinks/plugins/shared_preferences_ios/ios" :path: ".symlinks/plugins/shared_preferences_ios/ios"
url_launcher: url_launcher_ios:
:path: ".symlinks/plugins/url_launcher/ios" :path: ".symlinks/plugins/url_launcher_ios/ios"
SPEC CHECKSUMS: SPEC CHECKSUMS:
connectivity: c4130b2985d4ef6fd26f9702e886bd5260681467 connectivity: c4130b2985d4ef6fd26f9702e886bd5260681467
...@@ -56,8 +56,8 @@ SPEC CHECKSUMS: ...@@ -56,8 +56,8 @@ SPEC CHECKSUMS:
qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
shared_preferences_ios: aef470a42dc4675a1cdd50e3158b42e3d1232b32 shared_preferences_ios: aef470a42dc4675a1cdd50e3158b42e3d1232b32
url_launcher: b6e016d912f04be9f5bf6e8e82dc599b7ba59649 url_launcher_ios: 02f1989d4e14e998335b02b67a7590fa34f971af
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
COCOAPODS: 1.10.0 COCOAPODS: 1.11.2
import 'dart:async'; import 'dart:async';
import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:typed_data';
import 'package:connectivity/connectivity.dart'; import 'package:connectivity/connectivity.dart';
import 'package:digital_3g_common/backend_switcher.dart'; import 'package:digital_3g_common/backend_switcher.dart';
...@@ -468,6 +470,13 @@ class _HomePageState extends State<HomePage> { ...@@ -468,6 +470,13 @@ class _HomePageState extends State<HomePage> {
controller.scannedDataStream.listen((scanData) { controller.scannedDataStream.listen((scanData) {
if ((scanData.code?.isNotEmpty ?? false) && !_disconnected) { if ((scanData.code?.isNotEmpty ?? false) && !_disconnected) {
if (_lastResult != scanData.code) { if (_lastResult != scanData.code) {
// check for valid base64 or else cancel
try {
final Uint8List decoded = base64.decode(scanData.code!);
if (decoded.isEmpty) return;
} catch (e) {
return;
}
_qrResult = scanData; _qrResult = scanData;
_lastResult = _qrResult!.code!; _lastResult = _qrResult!.code!;
_bloc!.onAdd(_lastResult); _bloc!.onAdd(_lastResult);
......
...@@ -52,9 +52,10 @@ class VerificationBloc extends Bloc<VerificationEvent, VerificationState> { ...@@ -52,9 +52,10 @@ class VerificationBloc extends Bloc<VerificationEvent, VerificationState> {
_verification = response; _verification = response;
await _verificationStore!.writeAsString(json.encode(_verification!.toMap)); await _verificationStore!.writeAsString(json.encode(_verification!.toMap));
yield VerificationState.verified; yield VerificationState.verified;
} else if ((((await Connectivity().checkConnectivity()) == ConnectivityResult.none) && } else if (((((await Connectivity().checkConnectivity()) == ConnectivityResult.none) ||
(_verificationStore?.existsSync() ?? false)) || ((response?.hasError ?? false) &&
((response?.hasError ?? false) && response!.error == VerificationErrorType.server)) { response!.error == VerificationErrorType.server)) &&
(_verificationStore?.existsSync() ?? false))) {
// get verification from local storage // get verification from local storage
final loaded = final loaded =
VerificationResponse.fromMap(json.decode(await _verificationStore!.readAsString())); VerificationResponse.fromMap(json.decode(await _verificationStore!.readAsString()));
......
...@@ -213,7 +213,7 @@ packages: ...@@ -213,7 +213,7 @@ packages:
name: path_provider_android name: path_provider_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.8" version: "2.0.9"
path_provider_ios: path_provider_ios:
dependency: transitive dependency: transitive
description: description:
...@@ -234,7 +234,7 @@ packages: ...@@ -234,7 +234,7 @@ packages:
name: path_provider_macos name: path_provider_macos
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.3" version: "2.0.4"
path_provider_platform_interface: path_provider_platform_interface:
dependency: transitive dependency: transitive
description: description:
...@@ -255,7 +255,7 @@ packages: ...@@ -255,7 +255,7 @@ packages:
name: platform name: platform
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.2" version: "3.1.0"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
...@@ -297,7 +297,7 @@ packages: ...@@ -297,7 +297,7 @@ packages:
name: shared_preferences_android name: shared_preferences_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.8" version: "2.0.9"
shared_preferences_ios: shared_preferences_ios:
dependency: transitive dependency: transitive
description: description:
...@@ -379,7 +379,21 @@ packages: ...@@ -379,7 +379,21 @@ packages:
name: url_launcher name: url_launcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.15" version: "6.0.17"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.13"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.13"
url_launcher_linux: url_launcher_linux:
dependency: transitive dependency: transitive
description: description:
...@@ -407,7 +421,7 @@ packages: ...@@ -407,7 +421,7 @@ packages:
name: url_launcher_web name: url_launcher_web
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.4" version: "2.0.5"
url_launcher_windows: url_launcher_windows:
dependency: transitive dependency: transitive
description: description:
...@@ -428,7 +442,7 @@ packages: ...@@ -428,7 +442,7 @@ packages:
name: win32 name: win32
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.3.0" version: "2.3.1"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment