-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[local_auth] Api to stop authentication #2111
Changes from 1 commit
eeaa591
a8a84f9
bf5c75c
ca88f26
ce85ba6
93fab07
aed3a2b
2ed420b
0c31915
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ## 0.6.0+3 | ||
| ## 0.6.1 | ||
|
|
||
| * Added ability to stop authentication (For Android). | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,16 +91,15 @@ class LocalAuthentication { | |
| } | ||
|
|
||
| /// Returns true if auth was cancelled successfully. | ||
karan-rawal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// This api only works for Android. | ||
| /// Returns false if there was some error or no auth in progress. | ||
| /// | ||
| /// Returns [Future] bool true or false: | ||
| Future<bool> stopAuthentication() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, how would the Dart app decide to call this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For devices with in-display fingerprint sensor(assuming that authentication is in progress), if user clicks on any other button on the screen, the fingerprint scanning will still be in progress. Hence, we needed an API to stop the authentication in such scenarios.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the response!
This is the part that I don't get. Why would I allow user to click anything in my app if there's authentication in progress? The user is not authenticated so should not be interacting with the app at all. I was assuming that on-screen auth will show exactly the same dialog. The only difference would be where you touch. Could you please point me to a video or an article of some sort which shows cancelAuthentication in action?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mehmetf For in-display fingerprint scanners, we don't get any popup. We just get the fingerprint scanner icon. Assuming current behaviour of the plugin So this PR should solve the above problem. I hope I was clear in explaining. :)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very interesting. Something is broken in this flow though.
I am OK adding this API because it is supported on Android. However the use case you are describing seems very very wrong to me. The app should not be responsible for cancelling authentication if the user already authenticated. If you agree with me, could you take some time to research how the Android API is supposed to be used? In particular why would PIN entry not run success/failure callbacks? (https://github.com/flutter/plugins/blob/master/packages/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java#L142)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mehmetf Thanks for your quick response.
I'm not sure if the use case is wrong, but I have seen this flow in a lot of apps.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see! OK that makes more sense. So basically you app is offering two auth methods simultaneously and you want to cancel one if the user chooses the other one.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mehmetf Exactly. :) |
||
| if (_platform.isAndroid) { | ||
| return _channel.invokeMethod<bool>('stopAuthentication'); | ||
| } | ||
| final Future<bool> future = Future<bool>(() => true); | ||
| Completer<bool>().complete(future); | ||
| return future; | ||
| return Future<bool>.sync(() => true); | ||
| } | ||
|
|
||
| /// Returns true if device is capable of checking biometrics | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ description: Flutter plugin for Android and iOS device authentication sensors | |
| such as Fingerprint Reader and Touch ID. | ||
| author: Flutter Team <[email protected]> | ||
| homepage: https://github.com/flutter/plugins/tree/master/packages/local_auth | ||
| version: 0.6.0+3 | ||
| version: 0.6.1 | ||
|
|
||
| flutter: | ||
| plugin: | ||
|
|
@@ -16,7 +16,7 @@ dependencies: | |
| sdk: flutter | ||
| meta: ^1.0.5 | ||
| intl: ">=0.15.1 <0.17.0" | ||
| platform: ^2.0.0 | ||
| platform: ^2.0.0 | ||
|
|
||
| dev_dependencies: | ||
| flutter_test: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bug here for
authInProgress. We might set it to true and never actually callauthenticate.Could you chage line 41 to:
if (authInProgress.get())then add to line 62:
authInProgress.set(true);.Since this method always runs in the
UIThread, we technically don't need to use AtomicBoolean. You can also optionally change all of this to a normalbooleanprimitive.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved. Not changing it to
booleanprimitive. Since, I don't want things to break. :)