Skip to content

Commit

Permalink
Remove useSFSafariViewController for logout
Browse files Browse the repository at this point in the history
  • Loading branch information
poovamraj committed Nov 20, 2023
1 parent 5dc4f87 commit 91ed971
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 24 deletions.
2 changes: 1 addition & 1 deletion android/src/main/java/com/auth0/react/A0Auth0Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void onFailure(@NonNull AuthenticationException error) {
}

@ReactMethod
public void webAuthLogout(String scheme, boolean federated, String redirectUri, boolean useSFSafariViewController, Promise promise) {
public void webAuthLogout(String scheme, boolean federated, String redirectUri, Promise promise) {
WebAuthProvider.LogoutBuilder builder = WebAuthProvider.logout(this.auth0)
.withScheme(scheme);
if(federated) {
Expand Down
4 changes: 2 additions & 2 deletions ios/A0Auth0.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ - (dispatch_queue_t)methodQueue
[self.nativeBridge webAuthWithState:state redirectUri:redirectUri nonce:nonce audience:audience scope:scope connection:connection maxAge:maxAge organization:organization invitationUrl:invitationUrl leeway:leeway ephemeralSession:ephemeralSession useSFSafariViewController:useSFSafariViewController additionalParameters:additionalParameters resolve:resolve reject:reject];
}

RCT_EXPORT_METHOD(webAuthLogout:(NSString *)scheme federated:(BOOL)federated redirectUri:(NSString *)redirectUri useSFSafariViewController:(BOOL)useSFSafariViewController resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[self.nativeBridge webAuthLogoutWithFederated:federated redirectUri:redirectUri useSFSafariViewController:useSFSafariViewController resolve:resolve reject:reject];
RCT_EXPORT_METHOD(webAuthLogout:(NSString *)scheme federated:(BOOL)federated redirectUri:(NSString *)redirectUri resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[self.nativeBridge webAuthLogoutWithFederated:federated redirectUri:redirectUri resolve:resolve reject:reject];
}

RCT_EXPORT_METHOD(resumeWebAuth:(NSString *)url resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
Expand Down
5 changes: 1 addition & 4 deletions ios/NativeBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,11 @@ public class NativeBridge: NSObject {

}

@objc public func webAuthLogout(federated: Bool, redirectUri: String, useSFSafariViewController: Bool, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
@objc public func webAuthLogout(federated: Bool, redirectUri: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
let builder = Auth0.webAuth(clientId: self.clientId, domain: self.domain)
if let value = URL(string: redirectUri) {
let _ = builder.redirectURL(value)
}
if(useSFSafariViewController) {
let _ = builder.provider(WebAuthentication.safariProvider())
}
builder.clearSession(federated: federated) { result in
switch result {
case .success:
Expand Down
3 changes: 1 addition & 2 deletions src/internal-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ export type Auth0Module = {
webAuthLogout: (
scheme: string,
federated: boolean,
redirectUri: string,
useSFSafariViewController?: boolean
redirectUri: string
) => Promise<void>;
resumeWebAuth: (url: string) => Promise<void>;
saveCredentials: (credentials: Credentials) => Promise<void>;
Expand Down
4 changes: 0 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ export interface ClearSessionOptions {
* This will use older callback URL. See {@link https://github.com/auth0/react-native-auth0/blob/master/MIGRATION_GUIDE.md#callback-url-migration} for more details.
*/
useLegacyCallbackUrl?: boolean;
/**
* **iOS only:** Uses SFSafariViewController instead of ASWebAuthenticationSession.
*/
useSFSafariViewController?: boolean;
}

export interface GetUserOptions {
Expand Down
4 changes: 1 addition & 3 deletions src/webauth/__tests__/agent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,13 @@ describe('Agent', () => {
{
customScheme: 'test',
federated: true,
useSFSafariViewController: true,
}
);
expect(mock).toBeCalledWith(NativeModules.A0Auth0, clientId, domain);
expect(mockLogin).toBeCalledWith(
'test',
true,
'test://test.com/ios/com.my.app/callback',
true
'test://test.com/ios/com.my.app/callback'
);
});
});
Expand Down
9 changes: 1 addition & 8 deletions src/webauth/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,7 @@ class Agent {
parameters.domain
);

resolve(
await A0Auth0.webAuthLogout(
scheme,
federated,
redirectUri,
options.useSFSafariViewController ?? false
)
);
resolve(await A0Auth0.webAuthLogout(scheme, federated, redirectUri));
} catch (error) {
if (linkSubscription) {
linkSubscription.remove();
Expand Down

0 comments on commit 91ed971

Please sign in to comment.