-
Notifications
You must be signed in to change notification settings - Fork 46
Added webAuth cancel for ios to prevent active transaction errors #573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1 @@ | |||
../../../darwin/Classes/WebAuth/WebAuthCancelMethodHandler.swift |
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.
do we need these changes?
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.
Do you mean the WebAuthCancelMethodHandler class ?
@@ -49,6 +49,13 @@ public class WebAuthHandler: NSObject, FlutterPlugin { | |||
} | |||
|
|||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { | |||
|
|||
if call.method == "webAuth#cancel" { |
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.
suggest to have the call method name as part of string constants
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.
Adding this as part of the existing Method enum was failing the UTs as all the corresponding handlers expect arguments. Fixing that would require adding some explicit conditions in UTs and code which weren't looking good
webAuth.cancelWebAuth(); | ||
//Retry login | ||
} | ||
} |
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.
Please check the formatting of the code snippet. A code snippet that is not properly formatted hinders readability.
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.
done
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.
/// You need to call this method within your custom Web Auth provider implementation whenever the operation is | ||
/// cancelled by the user. | ||
/// ## Note: | ||
/// This is an iOS specific api |
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.
/// This is an iOS specific api | |
/// This is an iOS specific API. |
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.
Also, should it be a static method or not?
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.
Any particular reason to declare it as static ?
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.
In this case, it depends on how it's going to be used. In the case of the Auth0.swift SDK, the cancel()
method is meant to be called on its own (even possibly on the App Delegate) in circumstances where there is no expectation of an existing instance being around. Not sure what the usage would look like on Flutter apps, hence the question.
Please check the failing Android unit tests. Maybe something needs updating. |
Changes
This PR added support to cancel any ongoing transaction on iOS while using UL
References
https://github.com/auth0/Auth0.swift/blob/master/FAQ.md#5-how-to-resolve-the-failed-to-start-this-transaction-as-there-is-an-active-transaction-at-the-moment-error