Results 1 to 2 of 2

Thread: Logout change view sencha touch

  1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    84
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,318
    Answers
    3883
    Vote Rating
    1293
      0  

    Default

    What does the model for the localstorage store look like?

    I recommend against using the id config.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •