function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dmedme 

log off from an application

Hi,

 

Does any body can help me in devicing a logic to log off from an application using flex and salesforce?

 

thanks

dme

BrendanOCBrendanOC

Are you trying to log a particular user out of Salesforce from Flex?  If so, it should be pretty straight-forward.  If the Flex app is within the same domain as the user, you can call https://<Instance>.salesforce.com/secur/logout.jsp with that user's session cookie to terminate their session.

 

Hope that helps.

dmedme

hi,

 I am trying to log-off from my app. I am using the session id to login into my application.

If i go for log-off then it should just logoff from my app. it has to switch to the default app in sf . Any idea

 

thanks

dme

BrendanOCBrendanOC

I'm not sure I understand what you are trying to do.  If your app is within the context of <instance>.salesforce.com, users aren't logging in or out: they are already authenticated to <instance>.salesforce.com.  If your application is using a namespace, such as MyApp.<instance>.visual.force.com, the login mechanism is automatically handled by Salesforce when the user navigates from <instance> to <instance>.visual.force.com.

 

Is your application a Native application (hosted entirely on Force.com)?

How does Login work for your application?

Are users entering a username/password for only your application, or is authentication tied to Salesforce.com or SSO?

 

If you can provide some more details, I think I can help you.

dmedme

my app is developed with flex. It uses the session id after login into salesforce.com  below given the code snippets.

 

 

private function handleApplicationComplete( event:Event ):void{
   var o:Object = Application.application.parameters;
   if( o.hasOwnProperty('session_id') && StringUtil.trim(o.session_id) )
   {
	dmeModel.session_id = o.session_id;
   }
  if( o.hasOwnProperty('server_url') && StringUtil.trim(o.server_url) )
  {
       dmeModel.server_url = o.server_url;
  }
  login();
}
		
private function login():void {
 dmeModel.apex.protocol = 'https';
 var lr:LoginRequest = new LoginRequest();
 if( dmeModel.server_url )dmeModel.apex.serverUrl = dmeModel.server_url;
 if( !dmeModel.session_id ) Alert.show("Invalid session","Invalid");
    else{
      trace( '[session_id]' + dmeModel.session_id ;
      lr.session_id = dmeModel.session_id;
      lr.server_url = dmeModel.server_url;
    }
 lr.callback = new AsyncResponder(handleLoadData, DMEUtils.handleFault);
 dmeModel.apex.login(lr);
}

 Thus it logs in and also my app is a native app. For log off action currently i am redirecting to salesforce home page url.

 

The problem is if my app is choosen as default app then automatically if a user logs into salesforce my app get loaded and when he logs off from my app it is been redirected to homepage(home.jsp from SF) but force.com app still shows my app.

 

 

Is there any other better solutions available to change the app selected in force.com when my app logoff is initiated. Also like to know, if there is no other app is available then what can be the solution?.

 

BrendanOCBrendanOC

Ok, that makes more sense.

 

So the user is already logged in to Salesforce, then loads your app, which is Flex UI with Apex code on the server side. 

I don't think you need to perform additional login and logout steps in your code.  Your Flex app already has the user's session ID, so you don't need to login to Salesforce again.  Once the user is done with your app or wants to close it, you can just destroy the session id o.session_id in the Flex code, then close the browser window.  Technically the session ID will still be valid for a period of time (until it times out), but after your app closes, there will be no record of the Session ID.

 

Hope that helps!