I am new to sencha touch and trying make an app where user has to login to be able to use the app. Furthermore, I have created restful api for user authentication which responses user in json format if the authentication is correct. The api url for the user authentication looks like this: http://api-url/user/$username/$password.
My Login View:
Ext.define('NCAPP.view.tablet.LoginForm', {
extend: 'Ext.form.Panel',
xtype:'loginForm',
id:'loginForm',
requires:[
'Ext.form.Panel',
'Ext.form.FieldSet',
'Ext.field.Password',
'Ext.Img',
'Ext.field.Toggle'
],
config: {
items: [
{
xtype: 'image',
src:'resources/img/netcenter_logo.png',
height: 100
},
{
xtype: 'fieldset',
title: 'NCAPP LOGIN:',
items: [
{
xtype: 'textfield',
id:'fldUsername',
name:'username',
placeHolder: 'Username'
},
{
xtype: 'passwordfield',
id:'fldPassword',
name:'passowrd',
placeHolder: 'Password'
}
]
},
{
xtype: 'button',
id: 'btnLogin',
text: 'Login'
}
]
}
});
And I also have User Model:
Ext.define('NCAPP.model.User', {
extend:'Ext.data.Model',
config:{
fields:[
{ name:'id', type: 'int'},
{ name: 'username', type: 'string'},
{ name: 'netshop_id', type:'int'},
{ name: 'firstname', type: 'string'},
{ name: 'lastname', type: 'string'},
{ name: 'address', type: 'string'},
{ name:'password', type:'string'},
]
}
});
And My Login controller:
Ext.define('NCAPP.controller.tablet.LoginController', {
extend: 'Ext.app.Controller',
config: {
refs: {
loginForm:'loginForm'
},
control: {
'#btnLogin':{
tap:'onLoginButtonTap'
}
}
},
onLoginButtonTap:function(){
},
init:function(application){
}
});
As I have mentioned earlier, my api is completely restful. I think I can't use ajax proxy and i have to use rest proxy. My big question is how can pass the username and password to restful api?
Can any body help me with this (preferably with example)?