Ver código fonte

surface correct authentication reason everywhere

Neeraj Gupta 3 anos atrás
pai
commit
4369a24385

+ 9 - 8
lib/ui/settings/account_section_widget.dart

@@ -2,7 +2,6 @@ import 'dart:io';
 
 import 'package:flutter/material.dart';
 import 'package:flutter_sodium/flutter_sodium.dart';
-import 'package:logging/logging.dart';
 import 'package:photos/core/configuration.dart';
 import 'package:photos/services/user_service.dart';
 import 'package:photos/ui/app_lock.dart';
@@ -57,12 +56,12 @@ class AccountSectionWidgetState extends State<AccountSectionWidget> {
           behavior: HitTestBehavior.translucent,
           onTap: () async {
             AppLock.of(context).setEnabled(false);
-            final result = await requestAuthentication();
+            String reason = "please authenticate to view your recovery key";
+            final result = await requestAuthentication(reason: reason);
             AppLock.of(context)
                 .setEnabled(Configuration.instance.shouldShowLockScreen());
             if (!result) {
-              Logger("harami").info("Showing toast");
-              showToast("please authenticate to view your recovery key");
+              showToast(reason);
               return;
             }
 
@@ -96,11 +95,12 @@ class AccountSectionWidgetState extends State<AccountSectionWidget> {
           behavior: HitTestBehavior.translucent,
           onTap: () async {
             AppLock.of(context).setEnabled(false);
-            final result = await requestAuthentication();
+            String reason = "please authenticate to change your email";
+            final result = await requestAuthentication(reason: reason);
             AppLock.of(context)
                 .setEnabled(Configuration.instance.shouldShowLockScreen());
             if (!result) {
-              showToast("please authenticate to change your email");
+              showToast(reason);
               return;
             }
             showDialog(
@@ -124,11 +124,12 @@ class AccountSectionWidgetState extends State<AccountSectionWidget> {
           behavior: HitTestBehavior.translucent,
           onTap: () async {
             AppLock.of(context).setEnabled(false);
-            final result = await requestAuthentication();
+            String reason = "please authenticate to change your password";
+            final result = await requestAuthentication(reason: reason);
             AppLock.of(context)
                 .setEnabled(Configuration.instance.shouldShowLockScreen());
             if (!result) {
-              showToast("please authenticate to change your password");
+              showToast(reason);
               return;
             }
             Navigator.of(context).push(

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

@@ -68,12 +68,14 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
                         value: snapshot.data,
                         onChanged: (value) async {
                           AppLock.of(context).setEnabled(false);
-                          final result = await requestAuthentication();
+                          String reason =
+                              "please authenticate to configure two-factor authentication";
+                          final result =
+                              await requestAuthentication(reason: reason);
                           AppLock.of(context).setEnabled(
                               Configuration.instance.shouldShowLockScreen());
                           if (!result) {
-                            showToast(
-                                "please authenticate to configure two-factor authentication");
+                            showToast(reason);
                             return;
                           }
                           if (value) {
@@ -114,7 +116,8 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
               value: _config.shouldShowLockScreen(),
               onChanged: (value) async {
                 AppLock.of(context).disable();
-                final result = await requestAuthentication();
+                final result = await requestAuthentication(
+                    reason: "please authenticate to change lockscreen setting");
                 if (result) {
                   AppLock.of(context).setEnabled(value);
                   _config.setShouldShowLockScreen(value);