Revize 551
Přidáno uživatelem Roman Ševčík před téměř 15 roky(ů)
freenetis/trunk/kohana/application/controllers/login.php | ||
---|---|---|
$user_model=new User_Model();
|
||
$user_id = $user_model->login_request($this->input->post('username'),$this->input->post('password'));
|
||
|
||
$user = ORM::factory('user')->where(array('id' => $user_id))->find();
|
||
$member = ORM::factory('member')->where(array('id' => $user->member->id))->find();
|
||
if ($member->locked)
|
||
$user_id = NULL;
|
||
|
||
if ($user_id)
|
||
{
|
||
$this->session->set('username', $this->input->post('username'));
|
||
$this->session->set('user_id', $user_id);
|
||
$user_model->clear();
|
||
$user_model->find($user_id);
|
||
$member_id = $user_model->member_id;
|
||
$user_type = $user_model->type;
|
||
$this->session->set('member_id', $user_model->member_id);
|
||
$this->session->set('user_name', $user_model->name);
|
||
$this->session->set('user_surname', $user_model->surname);
|
||
$user_model->clear();
|
||
$user_model->where('member_id='.$member_id.' AND type!=\'user\'')->find();
|
||
$this->session->set('member_login', $user_model->login);
|
||
$user = ORM::factory('user')->where(array('id' => $user_id))->find();
|
||
$member = ORM::factory('member')->where(array('id' => $user->member->id))->find();
|
||
if (!$member->locked)
|
||
{
|
||
$this->session->set('username', $this->input->post('username'));
|
||
$this->session->set('user_id', $user_id);
|
||
$user_model->clear();
|
||
$user_model->find($user_id);
|
||
$member_id = $user_model->member_id;
|
||
$user_type = $user_model->type;
|
||
$this->session->set('member_id', $user_model->member_id);
|
||
$this->session->set('user_name', $user_model->name);
|
||
$this->session->set('user_surname', $user_model->surname);
|
||
$user_model->clear();
|
||
$user_model->where('member_id='.$member_id.' AND type!=\'user\'')->find();
|
||
$this->session->set('member_login', $user_model->login);
|
||
|
||
// information about users' last login is saved
|
||
$login_log = new Login_log_Model();
|
||
$login_log->user_id = $user_id;
|
||
$login_log->time = date("Y-m-d H:i:s");
|
||
$login_log->IP_address = server::remote_addr();
|
||
$login_log->save();
|
||
// information about users' last login is saved
|
||
$login_log = new Login_log_Model();
|
||
$login_log->user_id = $user_id;
|
||
$login_log->time = date("Y-m-d H:i:s");
|
||
$login_log->IP_address = server::remote_addr();
|
||
$login_log->save();
|
||
|
||
// enables logging of actions
|
||
// problem: session doesn't work inside ORM class
|
||
//$this->session->set('log', 1);
|
||
// enables logging of actions
|
||
// problem: session doesn't work inside ORM class
|
||
//$this->session->set('log', 1);
|
||
|
||
if ($this->session->get('referer') != '')
|
||
{
|
||
url::redirect(url_lang::base().$this->session->get('referer'));
|
||
if ($this->session->get('referer') != '')
|
||
{
|
||
url::redirect(url_lang::base().$this->session->get('referer'));
|
||
}
|
||
else
|
||
{
|
||
if ($user_type!='user')
|
||
url::redirect(url_lang::base().'members/show/'.$member_id);
|
||
else
|
||
url::redirect(url_lang::base().'users/show/'.$user_id);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if ($user_type!='user')
|
||
url::redirect(url_lang::base().'members/show/'.$member_id);
|
||
else
|
||
url::redirect(url_lang::base().'users/show/'.$user_id);
|
||
$error = url_lang::lang('texts.Your accout has been locked.').' '.url_lang::lang('texts.Please contact administrator.');
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if ($member->locked)
|
||
$error = url_lang::lang('texts.Your accout has been locked.').' '.url_lang::lang('texts.Please contact administrator.');
|
||
else
|
||
$error = url_lang::lang('texts.Username or password do not match.');
|
||
}
|
||
}
|
Také k dispozici: Unified diff
Opravena chyba v kontroleru login.