浏览代码

make it mandatory to pass authentication reason

Neeraj Gupta 3 年之前
父节点
当前提交
c205e78320

+ 2 - 1
lib/ui/lock_screen.dart

@@ -44,7 +44,8 @@ class _LockScreenState extends State<LockScreen> {
   Future<void> _showLockScreen() async {
   Future<void> _showLockScreen() async {
     _logger.info("Showing lockscreen");
     _logger.info("Showing lockscreen");
     try {
     try {
-      final result = await requestAuthentication();
+      final result = await requestAuthentication(
+          "please authenticate to view your memories");
       if (result) {
       if (result) {
         AppLock.of(context).didUnlock();
         AppLock.of(context).didUnlock();
       }
       }

+ 3 - 3
lib/ui/settings/account_section_widget.dart

@@ -57,7 +57,7 @@ class AccountSectionWidgetState extends State<AccountSectionWidget> {
           onTap: () async {
           onTap: () async {
             AppLock.of(context).setEnabled(false);
             AppLock.of(context).setEnabled(false);
             String reason = "please authenticate to view your recovery key";
             String reason = "please authenticate to view your recovery key";
-            final result = await requestAuthentication(reason: reason);
+            final result = await requestAuthentication(reason);
             AppLock.of(context)
             AppLock.of(context)
                 .setEnabled(Configuration.instance.shouldShowLockScreen());
                 .setEnabled(Configuration.instance.shouldShowLockScreen());
             if (!result) {
             if (!result) {
@@ -96,7 +96,7 @@ class AccountSectionWidgetState extends State<AccountSectionWidget> {
           onTap: () async {
           onTap: () async {
             AppLock.of(context).setEnabled(false);
             AppLock.of(context).setEnabled(false);
             String reason = "please authenticate to change your email";
             String reason = "please authenticate to change your email";
-            final result = await requestAuthentication(reason: reason);
+            final result = await requestAuthentication(reason);
             AppLock.of(context)
             AppLock.of(context)
                 .setEnabled(Configuration.instance.shouldShowLockScreen());
                 .setEnabled(Configuration.instance.shouldShowLockScreen());
             if (!result) {
             if (!result) {
@@ -125,7 +125,7 @@ class AccountSectionWidgetState extends State<AccountSectionWidget> {
           onTap: () async {
           onTap: () async {
             AppLock.of(context).setEnabled(false);
             AppLock.of(context).setEnabled(false);
             String reason = "please authenticate to change your password";
             String reason = "please authenticate to change your password";
-            final result = await requestAuthentication(reason: reason);
+            final result = await requestAuthentication(reason);
             AppLock.of(context)
             AppLock.of(context)
                 .setEnabled(Configuration.instance.shouldShowLockScreen());
                 .setEnabled(Configuration.instance.shouldShowLockScreen());
             if (!result) {
             if (!result) {

+ 3 - 4
lib/ui/settings/security_section_widget.dart

@@ -70,8 +70,7 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
                           AppLock.of(context).setEnabled(false);
                           AppLock.of(context).setEnabled(false);
                           String reason =
                           String reason =
                               "please authenticate to configure two-factor authentication";
                               "please authenticate to configure two-factor authentication";
-                          final result =
-                              await requestAuthentication(reason: reason);
+                          final result = await requestAuthentication(reason);
                           AppLock.of(context).setEnabled(
                           AppLock.of(context).setEnabled(
                               Configuration.instance.shouldShowLockScreen());
                               Configuration.instance.shouldShowLockScreen());
                           if (!result) {
                           if (!result) {
@@ -117,7 +116,7 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
               onChanged: (value) async {
               onChanged: (value) async {
                 AppLock.of(context).disable();
                 AppLock.of(context).disable();
                 final result = await requestAuthentication(
                 final result = await requestAuthentication(
-                    reason: "please authenticate to change lockscreen setting");
+                    "please authenticate to change lockscreen setting");
                 if (result) {
                 if (result) {
                   AppLock.of(context).setEnabled(value);
                   AppLock.of(context).setEnabled(value);
                   _config.setShouldShowLockScreen(value);
                   _config.setShouldShowLockScreen(value);
@@ -225,7 +224,7 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
         onTap: () async {
         onTap: () async {
           String reason = "please authenticate to view your active sessions";
           String reason = "please authenticate to view your active sessions";
           AppLock.of(context).setEnabled(false);
           AppLock.of(context).setEnabled(false);
-          final result = await requestAuthentication(reason: reason);
+          final result = await requestAuthentication(reason);
           AppLock.of(context)
           AppLock.of(context)
               .setEnabled(Configuration.instance.shouldShowLockScreen());
               .setEnabled(Configuration.instance.shouldShowLockScreen());
           if (!result) {
           if (!result) {

+ 1 - 2
lib/utils/auth_util.dart

@@ -2,8 +2,7 @@ import 'package:local_auth/auth_strings.dart';
 import 'package:local_auth/local_auth.dart';
 import 'package:local_auth/local_auth.dart';
 import 'package:logging/logging.dart';
 import 'package:logging/logging.dart';
 
 
-Future<bool> requestAuthentication(
-    {String reason = "please authenticate to view your memories"}) async {
+Future<bool> requestAuthentication(String reason) async {
   Logger("AuthUtil").info("Requesting authentication");
   Logger("AuthUtil").info("Requesting authentication");
   await LocalAuthentication().stopAuthentication();
   await LocalAuthentication().stopAuthentication();
   return await LocalAuthentication().authenticate(
   return await LocalAuthentication().authenticate(