[eluser]cahva[/eluser]
Hi,
I've made login with ExtJS and CI. I dont know how to explain it shortly but it doesnt differ much from doing it with "the normal way". As Graig said, we would need some more information. Have you started doing the login yet?
Anyway heres some pointers..
First choose or make your own auth and test it without using extjs first. So you would have controllers like this:
/auth/login
/auth/logout
etc..
When you have them working, you can create the login with extjs.
Heres my complete login.js
Code:
Ext.onReady(function() {
Ext.BLANK_IMAGE_URL = 'images/s.gif';
Ext.QuickTips.init();
var login_form = new Ext.FormPanel({
url: rootpath + 'json/auth/login',
renderTo: 'content',
frame: true,
title: 'Login',
width: 250,
waitMsgTarget: true,
items: [{
xtype: 'textfield',
fieldLabel: 'Username',
name: 'username',
allowBlank: false
},{
xtype: 'textfield',
inputType: 'password',
fieldLabel: 'password',
name: 'password',
allowBlank: false
}],
buttons: [{
text: 'Login',
handler: function() {
login_form.getForm().submit({
success: function(f,a) {
Ext.Msg.alert('Success',a.result.successmessage);
setTimeout ('[removed].replace(rootpath)', 2000 );
},
failure: function(f,a) {
Ext.Msg.alert('Failure',a.result.errormsg);
},
waitMsg:'Loading'
});
}
}]
});
var win = new Ext.Window({
layout:'fit',
width:300,
height:150,
closable: false,
resizable: false,
plain: true,
border: false,
items: [login_form]
});
win.show();
});
The removed piece of javascript should be window . location and is the redirect with js to the main page when login is succesful. Also I dont use the default Ext.Msg to inform (un)succesfull logins but I replaced those to this code so it should work for you.
As you can see theres this line:
url: rootpath + 'json/auth/login',
The rootpath is declared earlier in CI with base_url() to get the base url(doh!). I have separated json to its own directory. Heres the json/auth controller:
Code:
class Auth extends Controller {
function __construct()
{
parent::Controller();
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']))
{
redirect('');
}
}
function login()
{
if ($this->input->post('username') AND $this->input->post('password'))
{
$u = new User();
$u->username = $this->input->post('username');
$u->password = $this->input->post('password');
if ($u->login())
{
$response = array(
'success' => true,
'successmessage' => 'Login succesfull, redirecting..',
);
$data = array(
'logged_in' => true,
'user_id' => $u->id,
'firstname' => $u->firstname,
'lastname' => $u->lastname
);
$this->session->set_userdata($data);
}
else
{
$response = array(
'success' => false,
'errormsg' => 'Username or password was invalid'
);
}
echo json_encode($response);
}
}
}
Offcourse theres much more than this in my site but thats it in a nutshell. I myself have used Datamapper ORM as a backbone for the auth and everything else. I also extended the Controller with MY_Controller so I dont have to do the redirect in every controller that needs to have logged in user(in my case, every page

)