1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    84
    Vote Rating
    0
    koolll is on a distinguished road

      0  

    Default Unanswered: Logout change view sencha touch

    Unanswered: Logout change view sencha touch


    Hi I need to implement keep login in my sencha touch application
    Please see my code below:
    Login.js - Once user click login, it will store "sessionToken" in local storage.Then it will go to main Page
    Code:
    onBtnLoginClick: function(){
    Code:
        
                    var loginviewGetValue =  Ext.getCmp('loginview').getValues();
                    var bbid =  Ext.getCmp('bbID').getValue();
                    var bbpassword =  Ext.getCmp('bbPassword').getValue();
                        var LoginLS =   Ext.getStore('LoginLS');
        
        
        
        
        
                                            LoginLS.add({
                                                sessionId: 'sadsadsadasd'
                                               ,deviceId:'1'
                                               ,bb_id :bbid
                                               });
                                          
                                               LoginLS.sync();      
                                                  
                                           var mainForm= Ext.create('bluebutton.view.Main');
                                            Ext.Viewport.setActiveItem(mainForm);


    App.js~ Everytime launch function will check sessionToken in localStorage. If Localstorage is empty then it will go to login page.Else it will go to main Page

    Code:
      launch: function() {
    Code:
        
               
             
        
                // Destroy the #appLoadingIndicator element
                Ext.fly('appLoadingIndicator').destroy();
        
        
                // Initialize the main view
        
                     var LoginLS = Ext.getStore('LoginLS');
                     LoginLS.load();
        
                     var record =  LoginLS.getAt(0);
                        
        
                    if(record != undefined){
                        var sessionId = record.get('sessionId');
                       if (sessionId !=undefined){
                             Ext.Viewport.add(Ext.create('bluebutton.view.Main'));
                       }
                       else
                           Ext.Viewport.add(Ext.create('bluebutton.view.Login'));
        
                    }
                    else{
                       Ext.Viewport.add(Ext.create('bluebutton.view.Login'));
                       }
        
        //        Ext.create('bluebutton.view.TopMenuList');
        
            },


    Logout.js~Logout will clear the sessionToken and go to login page again
    Code:
    onLogoutClick: function scan() {
    Code:
                        var LoginLS = Ext.getStore('LoginLS');
                        
                        
                             Ext.Viewport.setMasked({
                                xtype: 'loadmask',
                                message: 'Loading...'
                            });
        
                        
                        
                         LoginLS.load();
        
                         var record =  LoginLS.getAt(0);
                           LoginLS.removeAll();
                            LoginLS.sync();
                           //Load a new view
        
        
        //                   Ext.getCmp('tabpanel').destroy();
                       
                          
        
                       
        
        
                        var loginForm = Ext.create('bluebutton.view.Login');
                        Ext.Viewport.setActiveItem(loginForm);   
        
                        Ext.Viewport.setMasked(false); // hide the load screen



    But i having a problem now. I not able to go back login page. It go to the blank page. Please give me some solution. Thanks.
    Here is the error i get
    Code:
     [WARN][Ext.data.Batch#runOperation] Your identifier generation strategy for the model does not ensure unique id's. Please use the UUID strategy, or implement your own identifier strategy with the flag isUnique. Console.js:35
    Code:
        [WARN][Ext.Component#constructor] Registering a component with a id (`loginview`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
        [WARN][Ext.Component#constructor] Registering a component with a id (`bbID`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
        [WARN][Ext.Component#constructor] Registering a component with a id (`bbPassword`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
        [WARN][Ext.Component#constructor] Registering a component with a id (`btnLogin`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
        [DEPRECATE][bluebutton.view.Login#show] Call show() on a component that doesn't currently belong to any container. Please add it to the the Viewport first, i.e: Ext.Viewport.add(component);


  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,604
    Answers
    3448
    Vote Rating
    818
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    What does the model for the localstorage store look like?

    I recommend against using the id config.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread