how to logout from portal

1712
2
Jump to solution
09-14-2021 01:35 AM
Arpa_PiemonteGeoportal_Team
Occasional Contributor II

Hi,

I can log in into my portal, but I cannot log out.

The log in starts after click a bottom.

This is my code (from https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#methods-summar...😞

// load the Portal and PortalQueryParams modules
require(["esri/portal/Portal",
 "esri/portal/PortalQueryParams"
], function(Portal, PortalQueryParams) {
  portal = new Portal();
  // Setting authMode to immediate signs the user in once loaded
  portal.authMode = "immediate";

  // Once portal is loaded, user signed in
  portal.load().then(function() {
    console.log(portal);

    // Create query parameters for the portal search
    // This object autocasts as new PortalQueryParams()
    let queryParams = {
      query: "owner:" + portal.user.username,
      sortField: "numViews",
      sortOrder: "desc",
      num: 20
    };
    // Query the items based on the queryParams created from portal above
    portal.queryItems(queryParams).then(createGallery);
  });
});

 Then the login windows is opened:

Arpa_PiemonteGeoportal_Team_0-1631607897038.png

And all works fine, I insert my credential and I can work with it.

 Then I want to log out to consent to other users to login, but I can't find in the documentation the way.

I tried:

    portal.user = null
    portal.cancelLoad()     
    portal = false
    delete portal;

But if I click the login bottom, the login windows doesn't appear and the old user is already connected!

Thanks

 

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

Portal load kicks in the IdentityManager authentication workflow. So you can use the IdentityManager destroyCredentials() method to sign out.

https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#des...

View solution in original post

0 Kudos
2 Replies
ReneRubalcava
Frequent Contributor

Portal load kicks in the IdentityManager authentication workflow. So you can use the IdentityManager destroyCredentials() method to sign out.

https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#des...

0 Kudos
Arpa_PiemonteGeoportal_Team
Occasional Contributor II

Yes, thanks, this works for me:

IdentityManager.destroyCredentials();
0 Kudos