From 31f6f587b3d3b80454a1308f6665bc784c3121fd Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Mon, 23 Dec 2024 13:35:04 +0545 Subject: [PATCH] feat: Return error when user cancels the presentation #3207 --- .../view/selective_disclosure_pick_page.dart | 17 ++++++++++++++++- .../view/query_by_example_present_page.dart | 8 ++++++++ .../qr_code_scan/cubit/qr_code_scan_cubit.dart | 3 ++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/dashboard/home/tab_bar/credentials/present/pick/selective_disclosure/view/selective_disclosure_pick_page.dart b/lib/dashboard/home/tab_bar/credentials/present/pick/selective_disclosure/view/selective_disclosure_pick_page.dart index abafaf7d1..9f9bb0e41 100644 --- a/lib/dashboard/home/tab_bar/credentials/present/pick/selective_disclosure/view/selective_disclosure_pick_page.dart +++ b/lib/dashboard/home/tab_bar/credentials/present/pick/selective_disclosure/view/selective_disclosure_pick_page.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:altme/app/app.dart'; @@ -199,7 +200,15 @@ class _SelectiveDisclosurePickViewState const SizedBox(height: 8), MyOutlinedButton( text: l10n.cancel, - onPressed: () => Navigator.of(context).pop(), + onPressed: () { + unawaited( + context.read().sendErrorToServer( + uri: widget.uri, + data: {'error': 'access_denied'}, + ), + ); + Navigator.of(context).pop(); + }, ), ], ), @@ -320,6 +329,12 @@ class _SelectiveDisclosurePickViewState ); if (!authenticated) { + unawaited( + context.read().sendErrorToServer( + uri: widget.uri, + data: {'error': 'access_denied'}, + ), + ); return; } } diff --git a/lib/dashboard/home/tab_bar/credentials/present/query_by_example_present/view/query_by_example_present_page.dart b/lib/dashboard/home/tab_bar/credentials/present/query_by_example_present/view/query_by_example_present_page.dart index 1bbadeae5..97cf0d775 100644 --- a/lib/dashboard/home/tab_bar/credentials/present/query_by_example_present/view/query_by_example_present_page.dart +++ b/lib/dashboard/home/tab_bar/credentials/present/query_by_example_present/view/query_by_example_present_page.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; @@ -84,6 +86,12 @@ class _QueryByExamplePresentPageState extends State { const SizedBox(height: 8), MyOutlinedButton( onPressed: () { + unawaited( + context.read().sendErrorToServer( + uri: widget.uri, + data: {'error': 'access_denied'}, + ), + ); Navigator.of(context).pop(); }, text: l10n.credentialPresentCancel, diff --git a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart index d5e3bd78c..2c8ff279d 100644 --- a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart +++ b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart @@ -1151,7 +1151,8 @@ class QRCodeScanCubit extends Cubit { 'error_description': 'Invalid client_id', }; unawaited( - scanCubit.sendErrorToServer(uri: state.uri!, data: error)); + scanCubit.sendErrorToServer(uri: state.uri!, data: error), + ); throw ResponseMessage(data: error); } }