當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sentry::validate_user方法代碼示例

本文整理匯總了PHP中Sentry::validate_user方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sentry::validate_user方法的具體用法?PHP Sentry::validate_user怎麽用?PHP Sentry::validate_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sentry的用法示例。


在下文中一共展示了Sentry::validate_user方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: action_sign_in

 public function action_sign_in()
 {
     $user = Session::get('oauth.user');
     $client = Session::get('oauth.client');
     // Check if user is signed in, if so redirect them on to /authorise
     if ($user && $client) {
         Response::redirect('oauth/authorise');
     }
     // Check there is are client parameters are stored
     if ($client === NULL) {
         $this->_fail('invalid_request', 'No client details have been saved. Have you deleted your cookies?', NULL, array(), 400);
         return;
     }
     // Errors
     $vars = array('error' => FALSE, 'error_messages' => array(), 'client_name' => $client->name);
     // If the form has been posted
     if (Input::post('validate_user')) {
         $u = trim(Input::post('username'));
         $p = trim(Input::post('password'));
         // Validate username and password
         if ($u === FALSE || empty($u)) {
             $vars['error_messages'][] = 'The username field should not be empty';
             $vars['error'] = TRUE;
         }
         if ($p === FALSE || empty($p)) {
             $vars['error_messages'][] = 'The password field should not be empty';
             $vars['error'] = TRUE;
         }
         // Check login and get credentials
         if ($vars['error'] === FALSE) {
             $user = Sentry::validate_user($u, $p, 'password');
             if ($user === FALSE) {
                 $vars['error_messages'][] = 'Invalid username and/or password';
                 $vars['error'] = TRUE;
             } else {
                 Session::set('oauth.user', (object) array('id' => $user->id, 'username' => $user->username, 'email' => $user->email, 'non_ad_user' => TRUE));
             }
         }
         // If there is no error then the user has successfully signed in
         if ($vars['error'] === FALSE) {
             Response::redirect('oauth/authorise');
         }
     }
     $this->template->body = View::forge('oauth/sign_in', $vars);
 }
開發者ID:wuhaa11,項目名稱:fuel-oauth2,代碼行數:45,代碼來源:oauth.php


注:本文中的Sentry::validate_user方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。