wiebo-troost / ionic-msal-native

Ionic wrapper for cordova-plugin-msal
MIT License
4 stars 3 forks source link

Signout is not working #2

Closed shreya-groot closed 3 years ago

shreya-groot commented 3 years ago
   logout(){
      var vm=this;
      this.msal.signOut().then((value)=>{
        console.log("value after user is logout",value)
        vm.sign_out="done";
      }).catch((error)=>{
        console.log("Error when user gets logout",error)
        vm.sign_out="error";
      })
    }

    login(){
      var vm=this;
      console.log("  vm.msal",  vm.msal)
      if(this.platform.is('android')==true){
        const options: any = {
          authorities: [
            {
              type: 'AAD',
              audience: 'AzureADMultipleOrgs',
              authorityUrl: "https://login.microsoftonline.com/organizations",
              default: true
            }
          ], 
          scopes: ['User.Read']
        };

        vm.msal.msalInit(options).then((initResult) => {
            console.log("Success result:", initResult); // "OK"
            vm.value=initResult;
            return initResult;
          },
          (err) => {
            console.log("Error result:", err);
            vm.value=err;
          })
          .then((d) => {
            console.log("d value is",d)
            vm.value="success"
            return vm.msal.signInInteractive()
            .then((v)=>{
          console.log("value after user is signed in",v)
            }).catch((error)=>{
              console.log("error",error)
              vm.value="error"
            });
          })
          .then((jwt) => {
            console.log("Signin result:", jwt);
            vm.value=jwt;
          });
      }

    }
I am trying to logout from my signed up account, but it is still showing user as logged in on calling the second function named as login() shown above
wiebo-troost commented 3 years ago

Hi!

Signout means that the next call to acquireTokenSilent is not going to work. I.e. you'll need a user interaction to gain access to the application again. It is however possible that the account remains signed in to Azure AD, so you're not required to enter your password again. This would be good for people who may be logged into their email on outlook.com with the same account as your app. Signing out from your app should not log them out of their email.

Hope that helps!