本文整理汇总了PHP中Model_User::find_by_username方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_User::find_by_username方法的具体用法?PHP Model_User::find_by_username怎么用?PHP Model_User::find_by_username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_User
的用法示例。
在下文中一共展示了Model_User::find_by_username方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_login
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);
}
示例2: before
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);
}
示例3: action_login
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);
}
示例4: action_login
/**
* Действие для авторизации пользователя
*/
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);
}
示例5: before
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);
}
示例6: before
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);
}
示例7: before
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));
}
}
示例8: before
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 . 'のログ';
}
示例9: get_user
/**
* @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;
}