1. #1
    Sencha User
    Join Date
    Oct 2013
    Location
    Minsk
    Posts
    39
    Vote Rating
    0
    samaelal is on a distinguished road

      0  

    Default How to save your login and password in the local memory

    How to save your login and password in the local memory


    Prompt! How to keep the local store username and password. There's this code:


    Code:
    Ext.define("MM.view.LoginView", {			extend : 'Ext.form.Panel',
    			xtype : 'loginForm',
    			id : 'loginForm',
    			requires : ['Ext.form.FieldSet', 'Ext.field.Password',
    					'Ext.field.Toggle'],
    			config : {
    				title : 'Log in',
    				iconCls : 'user',
    				items : [{
    							xtype : 'fieldset',
    							title : 'Авторизация',
    							items : [{
    										xtype : 'textfield',
    										label : 'Пользователь',
    										labelWidth : '40%',
    										id : 'userField',
    										hideAnimation : 'fadeOut',
    										showAnimation : 'fadeIn',
    										required : true,
    										labelAlign : 'top',
    										value : '',
    										name : 'user'
    									}, {
    										xtype : 'passwordfield',
    										label : 'Пароль',
    										labelWidth : '40%',
    										hideAnimation : 'fadeOut',
    										showAnimation : 'fadeIn',
    										id : 'passField',
    										required : true,
    										labelAlign : 'top',
    										value : '',
    										name : 'pass'
    									}, {
    										xtype : 'togglefield',
    										label : 'Запомнить пароль?',
    										labelWidth : '60%',
    										id : 'togEss',
    										name : 'spass',
    										value : false,
                                    handler: function()
                                    {
    
    
                                    }
    									}]
    						}, {
    							xtype : 'toolbar',
    							height : 70,
    							docked : 'bottom',
    							layout : {
    								pack : 'left',
    								type : 'hbox'
    							},
    							defaults : {
    								ui : 'plain'
    							},
    							items : [{
    										xtype : 'button',
    										ui : 'action',
    										height : 50,
    										width : 100,
    										id : 'doLogout',
    										flex : 1,
    										text : 'Закрыть'
    									}, {
    										xtype : 'button',
    										ui : 'action',
    										height : 50,
    										width : 100,
    										id : 'doLogon',
    										flex : 1,
    										text : 'Войти'
    									}
    
    
    							]
    						}]
    			},
                initialize : function(record) {
    
    
                }
    		});

    Code:
    Ext.define('MM.store.CurrentUser', {	extend: 'Ext.data.Store',
    	
    	config: {
    		model: 'MM.model.CurrentUser',
    		autoLoad: false
    	}
    });

    Code:
    Ext.define('MM.model.CurrentUser', {	extend: 'Ext.data.Model',
    	config: {
    		fields: [
    			{name: 'name', type: 'string'},
                {name: 'pass', type : 'string'},
                {name: 'spass', type : 'string'}
    		],
    
    
    		proxy: {
    			type: 'localstorage',
    			id: 'simple-login-data'
    		}
    	}
    });

    Advance very grateful for any help

  2. #2
    Sencha User armode's Avatar
    Join Date
    Nov 2011
    Location
    Germany / Darmstadt
    Posts
    63
    Vote Rating
    2
    armode is on a distinguished road

      0  

    Default


    You've just to add the credentials to the store and sync the store after that.
    Have a look into the docs: http://docs.sencha.com/touch/2.3.1/#...y.LocalStorage

    But I think it's not a good idea to save the password in an unsafe place like the local storage. You could use a cookie or maybe save it to the iOS keychain if you package your app with phonegap/cordova.

    Maybe someone else can say what's the best practice to implement an autologin feature?

  3. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,677
    Vote Rating
    749
    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


    I would agree this is a bad idea. Instead you need to save a token that you can then map to a session on the back end.
    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.

  4. #4
    Sencha User
    Join Date
    Oct 2013
    Location
    Minsk
    Posts
    39
    Vote Rating
    0
    samaelal is on a distinguished road

      0  

    Default


    ok! thank you .... and if you can you give an example

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar