public function action_login() { // Already logged in Auth::check() and Response::redirect('admin'); $val = Validation::forge(); if (Input::method() == 'POST') { $val->add('email', 'ユーザ名')->add_rule('required'); $val->add('password', 'パスワード')->add_rule('required'); if ($val->run()) { $auth = Auth::instance(); // check the credentials. This assumes that you have the previous table created if (Auth::check() or $auth->login(Input::post('email'), Input::post('password'))) { // credentials ok, go right in if (Config::get('auth.driver', 'Simpleauth') == 'Ormauth') { $current_user = Model\Auth_User::find_by_username(Auth::get_screen_name()); } else { $current_user = Model_User::find_by_username(Auth::get_screen_name()); } Session::set_flash('success', e('ようこそ、' . $current_user->username . 'さん')); Response::redirect('admin'); } else { $this->template->set_global('login_error', '失敗しました'); } } } $this->template->title = 'ログイン'; $this->template->content = View::forge('admin/login', array('val' => $val), false); }
public function before() { parent::before(); !Auth::check() and Response::redirect('/auth/login'); $this->current_user = Model_User::find_by_username(Auth::get_screen_name()); $this->template->set_global('current_user', $this->current_user); }
public function action_login() { if (Auth::check()) { Response::redirect('admin'); } $val = Validation::forge(); if (Input::method() == 'POST') { $val->add('email', 'Email or Username')->add_rule('required'); $val->add('password', 'Password')->add_rule('required'); if ($val->run()) { $auth = Auth::instance(); // check the credentials. This assumes that you have the previous table created if (Auth::check() or $auth->login(Input::post('email'), Input::post('password'))) { // credentials ok, go right in $current_user = Model_User::find_by_username(Auth::get_screen_name()); Session::set_flash('success', e('Welcome, ' . $current_user->username)); Response::redirect('admin'); } else { $this->template->set_global('login_error', 'Fail'); } } } $this->template->title = 'Login'; $this->template->content = View::forge('admin/login', array('val' => $val), false); }
/** * Действие для авторизации пользователя */ public function action_login() { // Already logged in \Auth::check() and \Response::redirect('admin/articles'); $val = \Validation::forge(); if (\Input::method() == 'POST') { $val->add('email', 'Логин')->add_rule('required'); $val->add('password', 'Пароль')->add_rule('required'); if ($val->run()) { $auth = \Auth::instance(); // check the credentials. This assumes that you have the previous table created if (\Auth::check() or $auth->login(\Input::post('email'), \Input::post('password'))) { // credentials ok, go right in if (\Config::get('auth.driver', 'Simpleauth') == 'Ormauth') { $current_user = \Model\Auth_User::find_by_username(\Auth::get_screen_name()); } else { $current_user = \Model_User::find_by_username(\Auth::get_screen_name()); } \Session::set_flash('success', 'Добро пожаловать, <b>' . $current_user->username . '</b>'); \Response::redirect('admin/articles'); } else { \Session::set_flash('error', 'Неверная комбинация логина и пароля.'); } } } $this->template->title = 'Авторизация'; $this->template->content = \View::forge('login', array('val' => $val), false); }
public function before() { parent::before(); // Assign current_user to the instance so controllers can use it $this->current_user = Auth::check() ? Model_User::find_by_username(Auth::get_screen_name()) : null; // Set a global variable so views can use it View::set_global('current_user', $this->current_user); }
public function before() { parent::before(); // Assign current_user to the instance so controllers can use it if (Config::get('auth.driver', 'Simpleauth') == 'Ormauth') { $this->current_user = Auth::check() ? Model\Auth_User::find_by_username(Auth::get_screen_name()) : null; } else { $this->current_user = Auth::check() ? Model_User::find_by_username(Auth::get_screen_name()) : null; } // Set a global variable so views can use it View::set_global('current_user', $this->current_user); }
public function before() { parent::before(); // Assign current_user to the instance so controllers can use it $this->current_user = Auth::check() ? Model_User::find_by_username(Auth::get_screen_name()) : null; // Set a global variable so views can use it View::set_global('current_user', $this->current_user); if ($this->current_user) { $this->status_where = array(array('status', '!=', null)); } else { $this->status_where = array(array('status', self::STATUS_DISP)); } }
public function before() { parent::before(); $data = array(); $this->username = $this->param('username'); $this->template = View::forge('template'); // todo related $this->user = $data['user'] = Model_User::find_by_username($this->username); if (empty($data['user'])) { Response::redirect('welcome/404', 'location', 404); } $data['log'] = Model_Post::count(array('where' => array_merge(array(array('user_id', $this->user->id)), $this->status_where))); $this->log_count = $data['log']; Model_Post::summary_userdata($data, $this->user->id); $this->template->set_global('description', $this->user->profiles->description); $this->template->content = View::forge('user/profile', $data); // 共通tpl $this->template->title = ' | ' . $this->user->profiles->full_name . 'のログ'; }
/** * @param null $default * * @return mixed|Model_User */ public function get_user($default = NULL) { if (!$this->current_user) { $user = parent::get_user($default = NULL); if ($user) { $this->current_user = Model_User::find_by_username($user->user_id); } } return $this->current_user; }