Hello everyone,
I do not understand very well the notation for this function: function (portalUser){
The parameter "portalUser" where is it populated and declared?
Is there any online converted that changes from AMD to other structure easier to read?
This function is used in this sample: https://developers.arcgis.com/javascript/3/jssamples/portal_oauth_inline.html
Thanks
function displayItems(){
new arcgisPortal.Portal(info.portalUrl).signIn().then(
function (portalUser){
console.log("Signed in to the portal: ", portalUser);
domAttr.set("userId", "innerHTML", portalUser.fullName);
domStyle.set("anonymousPanel", "display", "none");
domStyle.set("personalizedPanel", "display", "block");
queryPortal(portalUser);
}
).otherwise(
function (error){
console.log("Error occurred while signing in: ", error);
}
);
Solved! Go to Solution.
Jose,
It looks fine to me except that the signIn method returns a potalUser as the deferred result:
var portal = new arcgisPortal.Portal('http://[my organitation].maps.arcgis.com');
portal.signIn().then(function (loggedInUser){
console.log("Signed in to the portal: ", loggedInUser);
console.log(loggedInUser.fullName);
var myArray = null;
var myArray = loggedInUser.getGroups;
});
Are you adding a break point inside the then portion?
Jose,
"portalUser" is the promise result of the new arcgisPortal.Portal(info.portalUrl).signIn() function.
signIn():
Prompts the user using the IdentityManager and returns a deferred that, when resolved, returns the PortalUser for the input credentials.
https://developers.arcgis.com/javascript/3/jsapi/portal-amd.html#signin
Thanks Robert,
In this sample, how do I instantiate "portalUser" if I already log in into the web application. ?
I want to add this code to check the groups from an user that already logged in.
require([
"dojo/_base/array", ...
], function(array, ... ) {
portalUser.getFolders().then(function(folders){
array.forEach(folders,function(folder){
if(folder.title === 'javascript'){
folderid = folder.id;
}
});
});
...
});
http://ncsiapps.ncsi.gov.om/arcgis_js_api/sdk/jsapi/portaluser-amd.html
Jose,
You can get the portal user from the portal object using the getPortalUser() method:
https://developers.arcgis.com/javascript/3/jsapi/portal-amd.html#getportaluser
Thanks again,
what I do not understand is how the object "portal" gets instantiated? or how can declare an object myPortal = initialize it with "portal".
portal.on("load", function(){ console.log(portal.allSSL); });
The Portal class uses the IdentityManager to signin a user so if the user is already authenticated when you use Portal signIn I would not expect it to re-prompt for login so you should be good just calling portal signin.
What I don't understand is how the object "portal" gets populated. This is my function
require([
"esri/arcgis/Portal", ...
], function(arcgisPortal, ... ) {
//Retrieves user information.
checkUser: function() {
portal = new arcgisPortal ??????????? How is this object instantiated ??????
console.log(portal.allSSL);
console.log(portal.signIn());
console.log(portal.getPortalUser());
},
Jose,
If you are saying that your app is already logged in then that means the IdentityManger was used for some secured Portal resource. So just use:
var portal = new arcgisPortal.Portal('http://blahblah.maps.arcgis.com');
Thank you Robert.
One last questions,
how do I instantiate PortalGroup ?
var portalgroup = new ????
or do I need to run a query on Portal to get all groups?
Thanks