当前位置: 首页>>代码示例>>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;未经允许,请勿转载。