Page 1 of 1

Check if user is authorized to launch and Item

Posted: Mon Aug 08, 2011 1:25 pm
by esdaled
We have added some javascript to a page to lauch an Atrium Item. However, we have a number of users who are not authorized to use that item and would like to launch a different item for them.

We have tried the following code:

Code: Select all

function LaunchInquiry() {
	var tabObj = new Object();
	tabobj = Atrium.launchItem(29);
	if (!tabobj) {
		tabobj = Atrium.launchItem(216);
	}
}
However, tabobj is always undefined and both items launch for user authorized to both.

Is there a way to check if a user has item 29 on their navigation tree? and/or is there a way to check if launchItem was successful?

Re: Check if user is authorized to launch and Item

Posted: Tue Aug 09, 2011 10:16 am
by David
Atrium.launchItem() does not return a value. It actually cannot be made to return a value because it only opens the item after an Ajax call is done to first check whether the user is authorized to the item. Atrium.launchItem() returns immediatley as the Ajax call is started.

After the Ajax call...

If the user is not authorized, nothing at all happens. If the user is authorized, it will proceed to attempt to open the item. Of course, and additional security check is also done within the launched item, so the authority check is really just used to prevent a tab opening that will fail with an ugly "not authorized" message.

We could potentially add a callback parameter to this. A function could be passed to it which would be called on completion. A parameter could be passed to the function to indicate success/failure.

Would this suit your needs?

In regard to checking authorities, the only way to do that would be through an Ajax call to a program that checks the database. Although, I would think that this would be unneccessary if you were able to get feedback from Atrium.launchItem(). Is that right?

Re: Check if user is authorized to launch and Item

Posted: Tue Aug 09, 2011 12:08 pm
by esdaled
A callback function which received success/failure would work fine.

The Atrium User Guide should be updated as it indicates that Atrium.launchItem returns "a reference to the tab object being launched".

Thanks.

Re: Check if user is authorized to launch and Item

Posted: Tue Aug 09, 2011 12:11 pm
by David
Yes, that would be entirely incorrect -- sorry for any confusion.

We'll see about getting it updated and also adding the callback capability.

Re: Check if user is authorized to launch and Item

Posted: Wed Mar 07, 2012 11:59 am
by esdaled
Any update on this?

Re: Check if user is authorized to launch and Item

Posted: Thu Mar 08, 2012 1:03 pm
by David
Sorry. This is now in place, pending next release (3.3.3). An optional 3rd parameter of type "function" is added.

If the parameter is passed, the function will be called on completion of Atrium.launchItem(). A single boolean parameter will be passed to the function to indicate success/failure.