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


PHP Auth::instance方法代码示例

本文整理汇总了PHP中Auth::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::instance方法的具体用法?PHP Auth::instance怎么用?PHP Auth::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Auth的用法示例。


在下文中一共展示了Auth::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     parent::__construct();
     // Load profiler
     if (Kohana::config('config.enable_profiler')) {
         $this->profiler = new Profiler();
     }
     $this->auth = Auth::instance();
     $this->db = Database::instance();
     // Are we logged in? if not, do we have an auto-login cookie?
     if (!$this->auth->logged_in()) {
         // Try to login with 'remember me' token
         if (!$this->auth->auto_login()) {
             // Login user in via HTTP AUTH
             $this->auth->http_auth_login();
         }
     }
     // Get session information
     $this->user = Auth::instance()->get_user();
     // Check private deployment access
     $controller_whitelist = array('login', 'riverid', 'api', 'frontlinesms', 'smssync', 'nexmo');
     if (Kohana::config('settings.private_deployment')) {
         if (!$this->auth->logged_in('login') and !in_array(Router::$controller, $controller_whitelist)) {
             // Redirect to login form
             url::redirect('login');
         }
     }
     // Set default content-type header
     header('Content-type: text/html; charset=UTF-8');
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:30,代码来源:MY_Controller.php

示例2: action_signout

 public function action_signout()
 {
     #Sign out the user
     Auth::instance()->logout();
     #redirect to the user account and then the signin page if logout worked as expected
     Request::instance()->redirect('/admin/site/index');
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:7,代码来源:site.php

示例3: setTrackerListCount

 public function setTrackerListCount()
 {
     $auth = Auth::instance();
     $loggedInEmpNumber = $auth->getEmployeeNumber();
     $searchParameter = array('limit' => null, 'employeeId' => $loggedInEmpNumber);
     $this->trackListCount = $this->getPerformanceTrackerService()->getPerformanceTrackListCountByEmployee($searchParameter);
 }
开发者ID:adwalk,项目名称:juming,代码行数:7,代码来源:viewMyPerformanceTrackerListAction.class.php

示例4: delete

 public function delete($id = NULL)
 {
     if (Auth::instance()->get_user()->id == $this->id || Auth::instance()->get_user()->id == $id) {
         return;
     }
     parent::delete($id);
 }
开发者ID:ariol,项目名称:adminshop,代码行数:7,代码来源:User.php

示例5: __construct

 public function __construct()
 {
     if (!Auth::instance()->logged_in('admin')) {
         Event::run('system.404');
     }
     parent::__construct();
 }
开发者ID:peebeebee,项目名称:Simple-Photo-Gallery,代码行数:7,代码来源:admin_website.php

示例6: render

 public function render()
 {
     $view = View::factory('feed/' . $this->type . '_' . $this->action)->bind('lecture', $lecture)->bind('user', $user)->bind('span', $span)->bind('role', $role)->bind('feed_id', $feed_id)->bind('comments', $comments)->bind('url', $url);
     if ($this->action == 'add') {
         $lecture = ORM::factory('lecture', $this->respective_id);
         if ($this->check_deleted($lecture)) {
             return View::factory('feed/unavaliable')->render();
         }
     } else {
         if ($this->action == 'canceled') {
             $lecture = Model_Lecture::get_lecture_from_event($this->respective_id);
             $event = ORM::factory('event', $this->respective_id);
             if ($this->check_deleted($lecture)) {
                 return View::factory('feed/unavaliable')->render();
             }
             $view->bind('event', $event);
         }
     }
     $user = ORM::factory('user', $this->actor_id);
     $span = Date::fuzzy_span($this->time);
     $feed_id = $this->id;
     $curr_user = Auth::instance()->get_user();
     $role = $curr_user->role()->name;
     $comment = ORM::factory('feedcomment');
     $comment->where('feed_id', '=', $feed_id)->order_by('date', 'DESC');
     $comments = $comment->find_all();
     $url = Url::site('profile/view/id/');
     return $view->render();
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:29,代码来源:lecture.php

示例7: action_index

 public function action_index()
 {
     if (!Auth::instance()->logged_in() && isset($_POST['login'])) {
         $user = ORM::factory('User');
         $status = Auth::instance()->login($_POST['username'], $_POST['password'], true);
         if ($status) {
             HTTP::redirect('/');
         }
     }
     if (Auth::instance()->logged_in() && isset($_POST['logout'])) {
         Auth::instance()->logout();
     }
     if (!Auth::instance()->logged_in()) {
         Guestid::factory()->get_id();
     }
     $templateData['title'] = 'Главная.';
     $templateData['description'] = '';
     $template = View::factory('template')->set('templateData', $templateData);
     $content = View::factory("catalog");
     $content->get = $_GET;
     $content->shopArr = Model::factory('Shop')->getShop();
     $root_page = "index";
     $template->root_page = $root_page;
     $template->content = $content;
     $this->response->body($template);
 }
开发者ID:desc0n,项目名称:teleantenna,代码行数:26,代码来源:Index.php

示例8: getBestUser

 public static function getBestUser()
 {
     if (self::$bestUserRun) {
         return self::$bestUser;
     }
     $user = null;
     $segments = URL::getItems();
     foreach ($segments as $uname) {
         if (!in_array($uname, self::$skipNames)) {
             if (is_numeric($uname)) {
                 $user = ORM::factory("user", $uname);
             } else {
                 $user = ORM::factory("user")->where('vanity_url', '=', $uname)->find();
             }
             if ($user && $user->loaded()) {
                 break;
             }
         }
     }
     if (empty($user) || !$user->loaded()) {
         $user = Auth::instance()->get_user();
     }
     if (empty($user) || !$user->loaded()) {
         $user = new stdClass();
         $user->loaded = function () {
             return false;
         };
     }
     self::$bestUserRun = true;
     self::$bestUser = $user;
     return $user;
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:32,代码来源:widget.php

示例9: action_index

 public function action_index()
 {
     $message = false;
     $user = false;
     if (Arr::get($_POST, 'hidden') == 'form_sent') {
         if (Auth::instance()->login(Arr::get($_POST, 'username'), Arr::get($_POST, 'password'), Arr::get($_POST, 'remember'))) {
             $user = Auth::instance()->get_user();
             Session::instance()->set('username', $user->name . ' ' . $user->surname)->set('language', $user->language)->set('listsize', $user->listsize);
         }
     }
     if (Auth::instance()->logged_in()) {
         $user = Auth::instance()->get_user();
         Session::instance()->set('username', $user->name . ' ' . $user->surname)->set('language', $user->language)->set('listsize', $user->listsize);
         try {
             $server_config = $user->object->as_array();
             $fb_config = array('type' => 'pdo', 'connection' => array('dsn' => 'firebird:dbname=' . $server_config['config_server'] . ':' . $server_config['config_bdfile'], 'username' => $server_config['config_bduser'], 'password' => $server_config['config_bdpass']));
             Session::instance()->set('fb_config', $fb_config);
             $fb = Database::instance('fb', $fb_config);
             //$fb->connect();
             $this->request->redirect('/admin/');
         } catch (Database_Exception $e) {
             $message = __('error.connection_db');
             Auth::instance()->logout();
         }
     }
     $this->request->response = View::factory('login', array('message' => $message));
 }
开发者ID:artsec,项目名称:test1,代码行数:27,代码来源:login.php

示例10: before

	public function before()
	{
		parent::before();

		// The user is already logged in
		if (Auth::instance()->logged_in())
		{
			Request::instance()->redirect('');
		}

		// Load the configuration for this provider
		$config = Kohana::config('oauth.'.$this->provider);

		// Create a consumer from the config
		$this->consumer = OAuth_Consumer::factory($config);

		// Load the provider
		$this->provider = OAuth_Provider::factory($this->provider);

		if ($token = Cookie::get($this->cookie))
		{
			// Get the token from storage
			$this->token = unserialize($token);
		}
	}
开发者ID:rdenmark,项目名称:kohanajobs,代码行数:25,代码来源:base.php

示例11: action_index

 /** 
  * View the marksheet of a student by passing a user_id in get
  * so will be accessible only to the admin and teacher
  * if no user is passed, a filter will be applied to check if 
  * its the current user trying to view his/her own marksheet or 
  * if its the parant trying to view the marksheet of their pupil
  */
 public function action_index()
 {
     $relevant_user = Acl::instance()->relevant_user();
     if (!$relevant_user) {
         echo 'Not allowed';
         exit;
     }
     $user = Auth::instance()->get_user();
     $course_ids = $user->courses->find_all()->as_array(NULL, 'id');
     if ($course_ids) {
         $exams = ORM::factory('exam');
         $exams->where('course_id', 'IN', $course_ids)->group_by('examgroup_id');
         $exams = $exams->find_all()->as_array(NULL, 'examgroup_id');
         if ($exams) {
             $examgroups = ORM::factory('examgroup');
             $examgroups->where('publish', '=', '1');
             $examgroups->where('id', 'IN', $exams)->group_by('id');
             $examgroups = $examgroups->find_all();
         } else {
             $examgroups = "";
         }
     } else {
         $examgroups = "";
     }
     $view = View::factory('examresult/index')->bind('examgroup', $examgroups);
     $this->content = $view;
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:34,代码来源:exammarksheet.php

示例12: before

 public function before()
 {
     parent::before();
     $auth = \Auth::instance('SimpleAuth');
     if (\Input::get('logout')) {
         $auth->logout();
         \Response::redirect(\Uri::base(false) . 'admin/login');
     }
     $uri = explode('/', \Uri::string());
     if ($auth->check()) {
         if (count($uri) < 3 && (empty($uri[1]) || $uri[1] == 'login')) {
             \Response::redirect(\Uri::base(false) . 'admin/list');
         }
         // Load admin Config for List View and default to first tab
         $this->data['tabs'] = $this->template->tabs = \Config::get('admin.tabs');
         $this->data['table'] = $this->param('item', '');
         // get item from URI
         if (!$this->data['table']) {
             list($this->data['table']) = array_slice(array_keys($this->data['tabs']), 0, 1);
         }
         $this->template->table = $this->data['table'];
     } elseif (count($uri) > 1 && $uri[1] != 'login') {
         \Response::redirect(\Uri::base(false) . 'admin/login');
     }
     if ($this->auto_render === true) {
         // set up defaults
         $this->template->body = '';
     }
     return true;
 }
开发者ID:nathanharper,项目名称:fuel_cms_nh,代码行数:30,代码来源:master.php

示例13: 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

示例14: preExecute

 public function preExecute()
 {
     $sessionVariableManager = new DatabaseSessionManager();
     $sessionVariableManager->setSessionVariables(array('orangehrm_user' => Auth::instance()->getLoggedInUserId()));
     $sessionVariableManager->registerVarables();
     $this->setOperationName(OrangeActionHelper::getActionDescriptor($this->getModuleName(), $this->getActionName()));
 }
开发者ID:rabbitdigital,项目名称:HRM,代码行数:7,代码来源:baseRecruitmentAction.php

示例15: before

 /**
  * Automatically executed before the widget action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     // get all categories
     if ($this->categories != FALSE) {
         $this->cat_items = Model_Category::get_as_array();
         $this->cat_order_items = Model_Category::get_multidimensional();
     }
     // get all locations
     if ($this->locations != FALSE) {
         $this->loc_items = Model_Location::get_as_array();
         $this->loc_order_items = Model_Location::get_multidimensional();
     }
     if ($this->price != FALSE) {
         $this->price = TRUE;
     }
     // user
     if (Auth::instance()->logged_in()) {
         //subscriber
         // check if user is already subscribed
         $user_id = Auth::instance()->get_user()->id_user;
         $obj_subscriber = new Model_Subscribe();
         $subscriber = $obj_subscriber->where('id_user', '=', $user_id)->limit(1)->find();
         if ($subscriber->loaded()) {
             $this->subscriber = TRUE;
         }
         //if user logged in pass email and id
         $this->user_email = Auth::instance()->get_user()->email;
         $this->user_id = $user_id;
     } else {
         $this->user_id = 0;
     }
     //min - max price selected
     $this->min_price = $this->min_price;
     $this->max_price = $this->max_price;
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:41,代码来源:subscribers.php


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