Added authentication to show QR, edit or delete a code

- Used the requestAuthentication function in utils/auth_util.dart to perform the authentication
This commit is contained in:
Shivam Pachchigar 2023-10-05 15:11:38 +05:30
parent eaca45f5fe
commit 62a41c89c6
4 changed files with 35 additions and 30 deletions

View file

@ -12,6 +12,7 @@ import 'package:ente_auth/services/preference_service.dart';
import 'package:ente_auth/store/code_store.dart';
import 'package:ente_auth/ui/code_timer_progress.dart';
import 'package:ente_auth/ui/utils/icon_utils.dart';
import 'package:ente_auth/utils/auth_util.dart';
import 'package:ente_auth/utils/dialog_util.dart';
import 'package:ente_auth/utils/toast_util.dart';
import 'package:ente_auth/utils/totp_util.dart';
@ -370,6 +371,10 @@ class _CodeWidgetState extends State<CodeWidget> {
}
Future<void> _onEditPressed(_) async {
bool _isAuthSuccessful = await requestAuthentication("Authorize to shoq QR");
if(!_isAuthSuccessful) {
return;
}
final Code? code = await Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
@ -383,6 +388,10 @@ class _CodeWidgetState extends State<CodeWidget> {
}
Future<void> _onShowQrPressed(_) async {
bool _isAuthSuccessful = await requestAuthentication("Authorize to shoq QR");
if(!_isAuthSuccessful) {
return;
}
// ignore: unused_local_variable
final Code? code = await Navigator.of(context).push(
MaterialPageRoute(
@ -394,6 +403,10 @@ class _CodeWidgetState extends State<CodeWidget> {
}
void _onDeletePressed(_) async {
bool _isAuthSuccessful = await requestAuthentication("Authorize to shoq QR");
if(!_isAuthSuccessful) {
return;
}
final l10n = context.l10n;
await showChoiceActionSheet(
context,

View file

@ -19,7 +19,7 @@ class LifecycleEventHandler extends WidgetsBindingObserver {
}
break;
case AppLifecycleState.inactive:
case AppLifecycleState.hidden:
// case AppLifecycleState.hidden:
case AppLifecycleState.paused:
case AppLifecycleState.detached:
if (suspendingCallBack != null) {

View file

@ -197,10 +197,10 @@ packages:
dependency: "direct main"
description:
name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
url: "https://pub.dev"
source: hosted
version: "1.17.2"
version: "1.17.1"
computer:
dependency: "direct main"
description:
@ -699,10 +699,10 @@ packages:
dependency: "direct main"
description:
name: intl
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6
url: "https://pub.dev"
source: hosted
version: "0.18.1"
version: "0.18.0"
io:
dependency: transitive
description:
@ -747,10 +747,10 @@ packages:
dependency: "direct main"
description:
name: local_auth
sha256: "0cf238be2bfa51a6c9e7e9cfc11c05ea39f2a3a4d3e5bb255d0ebc917da24401"
sha256: "7e6c63082e399b61e4af71266b012e767a5d4525dd6e9ba41e174fd42d76e115"
url: "https://pub.dev"
source: hosted
version: "2.1.6"
version: "2.1.7"
local_auth_android:
dependency: transitive
description:
@ -795,18 +795,18 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.15"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.2.0"
meta:
dependency: transitive
description:
@ -1288,10 +1288,10 @@ packages:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.9.1"
sqflite:
dependency: "direct main"
description:
@ -1376,26 +1376,26 @@ packages:
dependency: transitive
description:
name: test
sha256: "13b41f318e2a5751c3169137103b60c584297353d4b1761b66029bae6411fe46"
sha256: "3dac9aecf2c3991d09b9cdde4f98ded7b30804a88a0d7e4e7e1678e78d6b97f4"
url: "https://pub.dev"
source: hosted
version: "1.24.3"
version: "1.24.1"
test_api:
dependency: transitive
description:
name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.5.1"
test_core:
dependency: transitive
description:
name: test_core
sha256: "99806e9e6d95c7b059b7a0fc08f07fc53fabe54a829497f0d9676299f1e8637e"
sha256: "5138dbffb77b2289ecb12b81c11ba46036590b72a64a7a90d6ffb880f1a29e93"
url: "https://pub.dev"
source: hosted
version: "0.5.3"
version: "0.5.1"
timezone:
dependency: transitive
description:
@ -1580,14 +1580,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.2"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
web_socket_channel:
dependency: transitive
description:
@ -1645,5 +1637,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=3.7.0"
dart: ">=3.0.0 <4.0.0"
flutter: ">=3.10.0"

View file

@ -50,7 +50,7 @@ dependencies:
http: ^0.13.4
intl: ^0.18.0
json_annotation: ^4.5.0
local_auth: ^2.1.3
local_auth: ^2.1.7
logging: ^1.0.1
modal_bottom_sheet: ^3.0.0-pre
move_to_background: ^1.0.2