wrobins / cordova-plugin-msal

Use the newest Microsoft MSAL library in your Cordova-based project!
Apache License 2.0
23 stars 63 forks source link

Signout closing the app #14

Closed kayRP closed 4 years ago

kayRP commented 4 years ago

Hello,

I am using your plugin for application signIn on android devices for a single account, I am facing an issue where as soon as I hit logout it is closing my app, here is my code for logout.

public logout(): void { const isMsalPluginAvailable = typeof (cordova.plugins.msalPlugin) !== 'undefined'; if (isMsalPluginAvailable) { // true this.msalPlugin.signOut( // after this step it is closing the app. (success) => { console.log('***DEBUGGGGGGGGG* MOBILE LOGOUT WORKS!!!', success); }, (err) => { console.log('***DEBUGGGGGGGGG* MOBILE LOGOUT FAILED!!!', err); } ); } }

All I am expecting is if it comes to either success or err callback I can do my logic.

wrobins commented 4 years ago

Hello! This is probably because of an unhandled exception in the native code, which I try to avoid (it should just print out an error), but I must have missed some point where an exception could be triggered. If you're able, could you run your application in debug mode in Android Studio and see if there's an error+stacktrace printed in the console? If so, please paste it here.

Thanks and sorry you're having trouble with this plugin!

kayRP commented 4 years ago

I run my application in debug mode but I don't see any error message printed, but when I put a breakpoint using chrome://inspect/#devices on chrome browser to debug remote devices, I see the behaviour where it gets closed. if (isMsalPluginAvailable) { // true this.msalPlugin.signOut( // after this step it is closing the app. (success) => {// expected this step to be called console.log('**DEBUGGGGGGGGG MOBILE LOGOUT WORKS!!!', success); }, (err) => { console.log('**DEBUGGGGGGGGG MOBILE LOGOUT FAILED!!!', err); } ); } }

hugoplatell commented 4 years ago

Hello, we're are having the same issues with the logout flow on Android.

The error stacktrace is as follows: Process: appid, PID: 20460 java.lang.NullPointerException: Attempt to invoke interface method 'com.microsoft.identity.client.IAccount com.microsoft.identity.client.IMultipleAccountPublicClientApplication.getAccount(java.lang.String)' on a null object reference at com.wrobins.cordova.plugin.MsalPlugin$8.run(MsalPlugin.java:353) at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:784)

Looking at the code it seems that the appMultipleClient is never initialized when you're using the single account mode. In this mode it is not necessary to check if the account is in any list, just logout directly is sufficient.

Removing this code solves the problem. See PR #15

jdipallo commented 2 years ago

I am experiencing this behavior still. logging out closes the app. not only that, but next time I try to login, I get an azure error about the account not matching the signed in account. thanks

pcaselas commented 9 months ago

@jdipallo did you manage to fix this?

I am experiencing the same. App is not closing after calling signOut method but it doesn't seem to work.

The current behaviour for me is if I log in for the first time interactively it works just fine, if I want to do it again, then it fails everytime, I have to remove the app and install again to be able to log in again.

rudi-minty commented 9 months ago

Simply do the signout function call (with no params), I now include it before starting interactive sign in (I.e. Only starting interactive sign in after signout callback), and  it's working well now. I am suppressing possible issues if signout fails however. Kind regardsRudi Minty072 191 4654Sent from my iPhoneOn 26 Jun 2022, at 02:09, jdipallo @.***> wrote: I am experiencing this behavior still. logging out closes the app. not only that, but next time I try to login, I get an azure error about the account not matching the signed in account. thanks

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

jdipallo commented 9 months ago

Hello. Ya know I don’t work for that client anymore and really can’t remember if or how I dealt with the issue. Apologies. On Sep 19, 2023 at 1:07 PM -0600, rudi-minty @.***>, wrote:

Simply do the signout function call (with no params), I now include it before starting interactive sign in (I.e. Only starting interactive sign in after signout callback), and  it's working well now. I am suppressing possible issues if signout fails however. Kind regardsRudi Minty072 191 4654Sent from my iPhoneOn 26 Jun 2022, at 02:09, jdipallo @.***> wrote: I am experiencing this behavior still. logging out closes the app. not only that, but next time I try to login, I get an azure error about the account not matching the signed in account. thanks

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.> — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.>