This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[local_auth] Api to stop authentication #2111
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
eeaa591
[local_auth] Added api to cancel android fingerprint authentication.
karan-rawal a8a84f9
[local_auth] Updated readme.
karan-rawal bf5c75c
Merge branch 'master' into ApiToStopAuthentication
karan-rawal ca88f26
Fixed Platform.isAndroid issue.
karan-rawal ce85ba6
Sync with remote
karan-rawal 93fab07
Sync with master
karan-rawal aed3a2b
Merge branch 'master' into ApiToStopAuthentication
karan-rawal 2ed420b
[local_auth] Fixed auth PR reviews.
karan-rawal 0c31915
Merge branch 'master' into ApiToStopAuthentication
karan-rawal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixed Platform.isAndroid issue.
- Loading branch information
commit ca88f2662692e0de04f56c32f0c33b074977bdb8
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,7 @@ class LocalAuthentication { | |
| }; | ||
| if (Platform.isIOS) { | ||
| args.addAll(iOSAuthStrings.args); | ||
| } else if (Platform.isAndroid) { | ||
| } else if (Platform.operatingSystem == "android") { | ||
| args.addAll(androidAuthStrings.args); | ||
| } else { | ||
| throw PlatformException( | ||
|
|
@@ -81,7 +81,7 @@ class LocalAuthentication { | |
| /// | ||
| /// Returns [Future] bool true or false: | ||
| Future<bool> stopAuthentication() { | ||
| if (Platform.isAndroid) { | ||
| if (Platform.operatingSystem == "android") { | ||
| return _channel.invokeMethod<bool>('stopAuthentication'); | ||
| } | ||
| final Future<bool> future = Future<bool>(() => true); | ||
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Out of curiosity, how would the Dart app decide to call this?
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.
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.
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.
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?
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.
@mehmetf For in-display fingerprint scanners, we don't get any popup. We just get the fingerprint scanner icon.
http://tiny.cc/e345ez
Assuming current behaviour of the plugin
In the link, you can see that we only get the fingerprint scanner icon and no popup. The user can still type the passcode, and click done. When user clicks done, and we navigate to another screen the authentication is still going on. The plugin doesn't provide any mechanism to cancel this authentication.
So this PR should solve the above problem.
I hope I was clear in explaining. :)
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.
Very interesting.
Something is broken in this flow though.
biometric.authenticate.biometric.authenticatenot return "success"? Why would we still expect a fingerprint scan?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)
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.
@mehmetf Thanks for your quick response.
biometric.authenticatejust overlays the fingerprint icon on top of it for scanning (The user can still interact with other part of the screen though).I'm not sure if the use case is wrong, but I have seen this flow in a lot of apps.
Just to add, the biometric API does show fingerprint dialog for physical fingerprint sensors. But it just shows fingerprint icon overlay for in-screen fingerprint sensors.
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.
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.
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.
@mehmetf Exactly. :)