I have a form on the login page with username and password text fields. Now wen the user registers for an account, I want to add him to the User model. And when he logs in I need to check whether the username/password combination is accurate to allow entry into the Sencha app.
I have no idea how to go about verifying the login/pass combo. Someone help !!! Here’s my code.
The Model :
App.models.Users = Ext.regModel('Expense',{
fields : [
{ name : 'id', type : 'integer'},
{ name : 'email', type : 'string'},
{ name : 'pass', type : 'string'}
],
validations : [
{ name : 'email', type : 'presence', message : 'cannot leave field blank'},
{ name : 'pass', type : 'presence', message : 'cannot leave field blank'}
],
proxy : {
type : 'localstorage',
id : 'user-creds'
}
});
Store :
App.stores.User = new Ext.data.Store ({
model : 'Users',
autoLoad : true,
autoSave : true
});
The Form is a basic one, with an xtype “textfield” for email, and “passwordfield” for password.
How do I verify that the details entered in the form match those stored in the localstorage???
When you tap the button to login, you need to try and find the email address entered in the store.
This method returns a record if a match is found. Once you have a record you can check that the password in the record matches the password entered on the form.
Refer to Store in the Sencha Touch docs
Update:
Assuming you’re following the MVC pattern…
You need:
In the view, your login button dispatches to the controller:
In your controller, the code retrieves the form values:
I hope this helps.