Auth0 Home Blog Docs

Swift login alert shows up when you logout

Exact same issue

This is our login code , we follow code sample.

  func login (handler:(() -> Void)?) {
        Auth0
            .webAuth()
            .scope(Constants.scope)
            .audience(Constants.domain)
            .start { [weak self] in
                switch $0 {
                case .failure(let error):
                    // Handle the error
                    print("Error: \(error)")
                case .success(let credentials):
                    _ = self?.store(credentials: credentials)
                    if let handler = handler {
                        handler()
                    }
                }
        }
    }

This is our logout code

    Auth0
            .webAuth()
            .clearSession(federated: true) { [weak self](sucess) in
                if sucess {
                    self?.accessTokenRefreshtimer?.suspend()
                    self?.accessTokenRefreshtimer = nil
                    self?.credentials = nil
                    self?.credentialsManager.clear()
                }                
        }

When we logout, the login alert will show up

Hey Sean!

Can you provide me with more context around it? I’d really appreciate if you share what version of the SDK you’re using + what device you’re testing it on.

Thanks a lot for that!

Version: Auth0 (1.14.1)

We tried on multiple devices such as X,8, and also simulators. So it is not specific to any particular device.

Thank you! Let me investigate it and get back to you once I find something!

1 Like

Let me know if you still need more information.

Thank you @sean.liu! I contacted you via DM regarding this case.

I also have the same issue.Is there any solution for this?

What is the solution to this? Calling
Auth0
.webAuth()
.clearSession(federated: true) { … }

automatically calls the Auth0 login screen

Hi, I have been getting the same issue. Any expected timeline on when this might be fixed?

Hi Konrad,

I have the same issues, please help me on this.

Hey there @thangarajan89!

Can you provide me with screenshots and some code snippets that I can dig into? Any info / context around it will be very useful!

For logout we are calling below code,

Auth0.webAuth().clearSession(federated: true) { (isLoggedOut) in
DispatchQueue.main.async {
let keychain = A0SimpleKeychain(service: “Auth0”)
keychain.clearAll()
//Perform UI Updates
self.credentials = nil
_ = self.credentialsManager.clear()
callback(isLoggedOut)
}
}

Can you also share screen by screen (the whole flow) how it behaves? The reason I’m asking it is that with previous developers asking we weren’t able to get enough info to troubleshoot that, hence having as much additional info as possible is very helpful!

talexis@sharpsoftwaredev.onmicrosoft.com

First we are calling login using below code,

    let scope = "openid profile offline_access email ssp:post"
    let audience = "https://device-messaging-apis”

    AuthManager.shared.patchMode = false
    Auth0
        .webAuth()
        .scope(scope)  
        .audience(audience)
        .start {
            switch $0 {
            case .failure(let error):
                print("Error: \(error)")
            case .success(let credentials):
                if(!AuthManager.shared.store(credentials: credentials)) {
                    print("Failed to store credentials")
                } else {
                    self.handleSuccessLogin()
                }
            }
    }

After execute this code we will get login like below screen shot

For logout,

After pressing Logout below code we are executing,
We are calling below code when pressing logout option,
Auth0.webAuth().clearSession(federated: true) { (isLoggedOut) in
DispatchQueue.main.async {
let keychain = A0SimpleKeychain(service: “Auth0”)
keychain.clearAll()
//Perform UI Updates
self.credentials = nil
_ = self.credentialsManager.clear()
callback(isLoggedOut)
}
}

After this we are getting default alert like below screen shot, (This alert is showing both login and logout)

Thank you a lot! Let me investigate it and get back to you once I have news to share!

Any news? Same error here

Any news yet? Having the same issue