当前位置: 首页>>代码示例>>PHP>>正文


PHP Model_User::find_by_username方法代码示例

本文整理汇总了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);
 }
开发者ID:sato5603,项目名称:fuelphp1st-2nd,代码行数:28,代码来源:admin.php

示例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);
 }
开发者ID:nobuhiko,项目名称:mylogbook,代码行数:7,代码来源:setting.php

示例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);
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:25,代码来源:admin.php

示例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);
 }
开发者ID:alexmon1989,项目名称:fcssadon.ru,代码行数:31,代码来源:admin.php

示例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);
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:8,代码来源:base.php

示例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);
 }
开发者ID:vienbk91,项目名称:fuelphp17,代码行数:12,代码来源:base.php

示例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));
     }
 }
开发者ID:nobuhiko,项目名称:mylogbook,代码行数:13,代码来源:base.php

示例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 . 'のログ';
 }
开发者ID:nobuhiko,项目名称:mylogbook,代码行数:19,代码来源:user.php

示例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;
 }
开发者ID:creat2012,项目名称:hustoj_official,代码行数:15,代码来源:Hoj.php


注:本文中的Model_User::find_by_username方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。