/**
* Action login
*/
public function action_login()
{
$post = $this->request->post();
$username = Arr::get($post, 'username');
$password = Arr::get($post, 'password');
$remember = Arr::get($post, 'remember') ?: 0;
// If there is post login
if ($this->request->post('login')) {
// ログインチェック
if (Auth::instance()->login($username, $password, $remember)) {
// ロールチェック
if (Auth::instance()->logged_in('direct') or Auth::instance()->logged_in('admin') or Auth::instance()->logged_in('edit')) {
// Add success notice
Notice::add(Notice::SUCCESS, Kohana::message('auth', 'login_success'), array(':user' => $username));
// Redirect to home
$this->redirect(URL::site($this->settings->backend_name, 'http'));
} else {
// Add error notice
Notice::add(Notice::ERROR, Kohana::message('auth', 'login_refusal'), NULL, Kohana::message('auth', 'login_refusal_messages'));
}
} else {
// Add error notice
Notice::add(Notice::ERROR, Kohana::message('auth', 'login_failed'), NULL, Kohana::message('auth', 'login_failed_messages'));
}
}
/**
* View
*/
// Get content
$content_file = Tpl::get_file('login', $this->settings->back_tpl_dir . '/auth');
$this->content = Tpl::factory($content_file)->set('post', $post);
}