hey DatacenterHellas,
Your best bet is to not login via an AJAX call. Just set
"standardSubmit: true" in your ExtJS login FormPanel config and call
"MyFormPanel.getForm().submit({method: 'POST'});". Now you can let
CakePHP handler your redirects server-side. On failure, you login page
will just reload. This works very well for me.
Here's some ExtJS code showing details of the login form:
Ext.namespace('CRM');
var crmLogin = {};
Ext.onReady(function(){
var crm_center = new Ext.Panel({
region: 'center',
layout: 'fit',
bodyBorder: false, border: false, hideBorders: true,
collapsible: false,
bodyStyle: 'border-style: none;',
width: 300,
items:
[
{
contentEl: 'center1'
}
]
});
var viewport = new Ext.Viewport({
layout: 'border',
items:
[
new Ext.BoxComponent({
title: 'North',
region: 'north',
el: 'north',
height: 80
}), new Ext.BoxComponent({
title: 'South',
region: 'south',
el: 'footer',
height: 30
}),
crm_center
]
});
Ext.QuickTips.init();
crmLogin = new Ext.FormPanel({
labelWidth: 70,
url: '/users/login',
frame: true,
title: 'Application Login',
width: 284,
bodyStyle: 'padding: 10px 0 5px 20px;',
defaultType: 'textfield',
standardSubmit: true,
monitorValid: true,
items:
[
{
name: '_method',
xtype: 'hidden',
value: 'POST'
},{
id: 'CRM-username',
fieldLabel: 'Username',
name: 'data[User][username]',
allowBlank: false
},{
id: 'CRM-password',
fieldLabel: 'Password',
name: 'data[User][password]',
inputType: 'password',
allowBlank: false
}
],
buttons:
[
{
text: 'Login',
formBind: true,
type: 'submit',
handler: function() {
CRM.login(crmLogin);
}
}
]
});
var win = new Ext.Window({
layout: 'fit',
width: 300,
height: 150,
closable: false,
resizable: false,
plain: true,
items: crmLogin
});
// defer delay seems to help with rendering of login form
(sometimes button is placed too low on form).
(function(){
win.show();
var mapPassword = new Ext.KeyMap('CRM-password', {
key: 13, // or Ext.EventObject.ENTER
fn: function() {CRM.login(crmLogin);}
,scope: crmLogin
});
var mapUsername = new Ext.KeyMap('CRM-username', {
key: 13, // or Ext.EventObject.ENTER
fn: function() {CRM.login(crmLogin);}
,scope: crmLogin
});
}).defer(200);
(function(){
crmLogin.getForm().findField('data[User][username]').focus();
}).defer(700);
});
CRM.login = function(loginFormPanel) {
loginFormPanel.ownerCt.hide();
Ext.MessageBox.wait('Logging in...', 'Please wait...');
loginFormPanel.getForm().submit({method: 'POST'});
};
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---