1
votes

We are migrating out Adobe Flex application to Adobe Air application and lots of feature are working fine .But the main issue which we are getting how to clear all the data/record/session after logout?

  1. Login the Adobe Air application with userid/password .
  2. After Successful login just go any menu item .
  3. Click the logout button.
  4. User redirect to login page.
  5. User login again it will show same Window from where user did logout with all the data.

So in Adobe Air how to clear the session data or how to clear all the component when user going to logout?

1
Please add your code to know how I can help you.Joe Taras
@JoeTaras Thanks for your comment.Which part of code you want to see ? in logout button click i am calling sessionManager.logout() method which is Flex code which is working for flash project .In Adobe Air do we have any session object or we have to remove all the components one by oneSubodh Joshi
When I do the logOut operation, usually, I destroy all my unuseful object and if I have an userLogged variable, reset it. So when I reload my login page, clean my text not binded with businnes object variable. So when I try to login again, I build in that moment the object to send on back end. Important I reset all autheticated channelJoe Taras
Any Sample code you have how you are doing in Adobe AIR?Subodh Joshi

1 Answers

3
votes

I add here, as you want, a snippet of code about logout from application:

public function logoutApplication(isSessionDown:Boolean=false):void
{
    // This method close other open windows (because in AIR you can open more than one window)
    closeOtherWindows();

    // Here I want to manage a sessionExpired variable in model locator so I can use for further aim
    if (CoreML.getInstance()!=null && CoreML.getInstance().sessionExpired){
        ModelLocator.getInstance().sessionExpired=true;
        CoreML.getInstance().sessionExpired=false;
    }

    // Here I remove all opened popup
    var listPopUp:IChildList = FlexGlobals.topLevelApplication.systemManager.popUpChildren;
    for (var i:int = 0; i < listPopUp.numChildren; i++) {
        var curr:IFlexDisplayObject = listPopUp.getChildAt(i) as IFlexDisplayObject;
        try {
            if (curr != null) {
                PopUpManager.removePopUp(curr);
            }
        }
        catch(ex:ExceptionFrontEndHandler) {
            // If you arrive here, it isn't a popup
        }
    }

    // here I update my component menu (it's business logic is not important)
    if (this.cntComponentMenu != null) {
        var newMenuComp:ComponentMenu = new ComponentMenu();
        newMenuComp.container=this;
        this.cntComponentMenu.removeAllElements();
        this.cntComponentMenu.addElement(newMenuComp);
    }

    // Here I change the state of my main MXML to login and clean the text box (not binded with BO)
    this.currentState='login';
    if (this.cntLogin!=null){
        this.cntLogin.currentState='State1';
        this.cntLogin.validateNow();
        this.cntLogin.userId.text="";
        this.cntLogin.password.text="";
    }
            
    if (!isSessionDown) EnvDispatcher.resetInfoSession(this);
        else mypackage.ModelLocator.getInstance().logout=true;
}

Here the code in result command of EnvDispatcher.resetInfoSession:

if (this.evt.sender!=null && this.evt.sender is UncertaintyAIR) {
        var pnl:MyApplication = this.evt.sender as MyApplication;
        pnl.currentState='login';
        pnl.validateNow();
        pnl.groupLogin.removeAllElements();
        LoginDispatcher.logout();
        LoginDispatcher.logoutSecure();
        mypackage.ModelLocator.getInstance().logout=true;
        var loginView:LoginView = new LoginView();
        loginView.container=pnl;
        pnl.groupLogin.addElement(loginView);
}