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


PHP Users::authenticate方法代码示例

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


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

示例1: train

 function train($f3)
 {
     // Check if Logged In User is Allowed to Train
     if (!$f3->get('SESSION.active') || !$f3->get('SESSION.admin') && !\R::findOne('trainings', 'users_id=? AND tools_id=? AND level=?', array($f3->get('SESSION.id'), $this->D->id, 'T'))) {
         throw new \Exception('You are not authorized to train for this machine.');
     }
     if ($f3->get('POST')) {
         // Check Instructor Validity
         if ($f3->get('POST.instructor') != $f3->get('SESSION.username')) {
             if (!$f3->get('SESSION.admin')) {
                 throw new \Exception('Cannot Change Instructor');
             }
         }
         if (!($instructor = \R::findOne('users', 'username=? AND active=1', array($f3->get('POST.instructor'))))) {
             throw new \Exception('Invalid Instructor Username');
         }
         $f3->set('instructor', $instructor);
         if ($f3->exists('POST.username')) {
             // Ensure User Checked the Affirmation
             if (!$f3->get('POST.affirmation')) {
                 throw new \Exception('Did not check legal aggreement box.');
             }
             // Get Trained User
             $user = new Users($f3);
             $user->authenticate($f3);
             $user->update_user($f3);
             $this->create_record($f3, $user->D, $instructor);
         }
     }
     $f3->set('data.training_levels', json_decode($f3->get('data.training_levels')));
     show_page($f3, 'trainings.train');
 }
开发者ID:neyre,项目名称:tools.olin.edu,代码行数:32,代码来源:trainings.php

示例2: users_after_pie_reroute

function users_after_pie_reroute($params, &$stop_dispatch)
{
    $uri = Pie_Dispatcher::uri();
    $app = Pie_Config::expect('pie', 'app');
    $ma = $uri->module . '/' . $uri->action;
    $requireComplete = Pie_Config::get('users', 'requireComplete', array());
    if (isset($requireComplete[$ma])) {
        $redirect_action = is_string($requireComplete[$ma]) ? $requireComplete[$ma] : "{$app}/login";
        $test_complete = true;
    } else {
        $requireLogin = Pie_Config::get('users', 'requireLogin', array());
        if (!isset($requireLogin[$ma])) {
            // We don't have to require complete or login here
            return;
        }
        $redirect_action = is_string($requireLogin[$ma]) ? $requireLogin[$ma] : "{$app}/login";
    }
    // First, try to get the user
    $user = Users::loggedInUser();
    if (!$user) {
        // Try authenticating with facebook
        $module = Pie_Dispatcher::uri()->module;
        $app_id = Pie_Config::expect('users', 'facebookApps', $module, 'appId');
        $user = Users::authenticate('facebook', $app_id);
    }
    if (!$user) {
        $uri->onSuccess = $uri->module . '/' . $uri->action;
        $uri->onCancel = "{$app}/welcome";
        if ($uri->onSuccess === $redirect_action) {
            // avoid a redirect loop
            $uri->onSuccess = "{$app}/home";
        }
        $parts = explode('/', $redirect_action);
        $uri->action = $parts[0];
        $uri->action = $parts[1];
    }
    // If have requireLogin but not requireComplete, then
    // simply change the underlying URI without redirecting
    if (empty($test_complete)) {
        return;
    }
    // If we are here, we should check if the user account is complete
    $complete = Pie::event('users/account/complete');
    if ($complete) {
        // good, nothing else to complete
        return;
    }
    // redirect to account page
    $account_action = Pie_Config::expect('users', 'accountAction', $uri->module);
    if ($ma != $account_action) {
        // Make the user launch into setting up their account.
        // If they want to return to this URL later, they can do it on their own.
        Pie_Response::redirect($account_action);
        $stop_dispatch = true;
        return;
    }
}
开发者ID:EGreg,项目名称:PHP-On-Pie,代码行数:57,代码来源:reroute.php

示例3: Users_authenticate_post

function Users_authenticate_post()
{
    // Authenticate the logged-in user with the provider via the app
    // It will try to set an email address for the user if one isn't set yet
    $user = Users::authenticate('facebook', null, $authenticated, true);
    if (!$user) {
        throw new Users_Exception_NotLoggedIn();
    }
    Users::setLoggedInUser($user);
}
开发者ID:dmitriz,项目名称:Platform,代码行数:10,代码来源:post.php

示例4: login

 /**
  * Authenticates the user. If the authentication fails, displays the login 
  * page. Otherwise, sets the user id to the 'user' session variable and 
  * redirects to checkout. 
  */
 public static function login()
 {
     $params = $_POST;
     $user = Users::authenticate($params['username'], $params['password']);
     if ($user) {
         $_SESSION['user'] = $user->id;
         Redirect::to('/kassa', array('message' => 'Kirjautuminen onnistui!'));
     } else {
         View::make('user/login.html', array('message' => 'Väärä käyttäjätunnus tai salasana!', 'username' => $params['username']));
     }
 }
开发者ID:nadeka,项目名称:pizzataivas,代码行数:16,代码来源:users_controller.php

示例5: actionIndex

 public function actionIndex()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect("/");
     }
     $user = new Users();
     if (Yii::app()->request->isPostRequest && isset($_POST['Auth'])) {
         $user->setAttributes($_POST['Auth']);
         $user->authenticate();
         if (!$user->hasErrors()) {
             $this->redirect("/");
         }
     }
     $this->render("index", array("model" => $user));
 }
开发者ID:CrystReal,项目名称:Site_backend,代码行数:15,代码来源:AuthController.php

示例6: actionIndex

 public function actionIndex()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect($this->createUrl("/personal/cabinet/index"));
     }
     $user = new Users();
     if (Yii::app()->request->isPostRequest && isset($_POST['Auth'])) {
         if (!isset($_POST['YII_CSRF_TOKEN']) || $_POST['YII_CSRF_TOKEN'] !== Yii::app()->getRequest()->getCsrfToken()) {
             throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
         }
         $user->setAttributes($_POST['Auth']);
         $user->authenticate();
         if (!$user->hasErrors()) {
             $this->redirect($this->createUrl("/personal/cabinet/index"));
         }
     }
     $this->Title = "Авторизация";
     $this->render("index", array("model" => $user));
 }
开发者ID:CrystReal,项目名称:Site_frontend,代码行数:19,代码来源:AuthController.php

示例7: authenticate

 /**
  * Performs an authentication attempt
  *
  * @throws Zend_Auth_Adapter_Exception If authentication cannot be performed
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     try {
         $this->user = Users::authenticate($this->email, $this->password);
     } catch (Exception $e) {
         if ($e->getMessage() == Users::WRONG_PW) {
             return $this->result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, self::BAD_PW_MESSAGE);
         }
         if ($e->getMessage() == Users::NOT_FOUND) {
             return $this->result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, self::NOT_FOUND_MESSAGE);
         }
         if ($e->getMessage() == Users::BAN) {
             return $this->result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, self::BAN_MESSAGE);
         }
         if ($e->getMessage() == Users::NOT_VERIFY) {
             return $this->result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, self::VERIFY_MESSAGE);
         }
     }
     return $this->result(Zend_Auth_Result::SUCCESS);
 }
开发者ID:abtris,项目名称:retreatin,代码行数:26,代码来源:Adapter.php

示例8: elseif

 * - feed.php?id=12
 *
 * @link http://blogs.law.harvard.edu/tech/rss RSS 2.0 Specification
 *
 * @author Bernard Paques
 * @author GnapZ
 * @tester Pat
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
// ensure we only provide public content through newsfeeds
$context['users_without_teasers'] = 'Y';
// check network credentials, if any -- used by winamp and other media players
if ($user = Users::authenticate()) {
    Surfer::empower($user['capability']);
}
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
    $id = $context['arguments'][0];
} elseif (Surfer::is_logged()) {
    $id = Surfer::get_id();
}
$id = strip_tags($id);
// get the item from the database
$item = Users::get($id);
// associates can do what they want
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:feed.php

示例9: register

 /**
  * Registers a user in the system.
  * @method register
  * @static
  * @param {string} $username The name of the user
  * @param {string|array} $identifier Can be an email address or mobile number. Or it could be an array of $type => $info
  * @param {string} [$identifier.identifier] an email address or phone number
  * @param {array} [$identifier.device] an array with keys "deviceId", "platform", "version"
  *   to store in the Users_Device table for sending notifications
  * @param {array|string} [$icon=array()] Array of filename => url pairs
  * @param {string} [$provider=null] Provider such as "facebook"
  * @param {array} [$options=array()] An array of options that could include:
  * @param {string} [$options.activation] The key under "Users"/"transactional" config to use for sending an activation message. Set to false to skip sending the activation message for some reason.
  * @return {Users_User}
  * @throws {Q_Exception_WrongType} If identifier is not e-mail or modile
  * @throws {Q_Exception} If user was already verified for someone else
  * @throws {Users_Exception_AlreadyVerified} If user was already verified
  * @throws {Users_Exception_UsernameExists} If username exists
  */
 static function register($username, $identifier, $icon = array(), $provider = null, $options = array())
 {
     if (is_array($provider)) {
         $options = $provider;
         $provider = null;
     }
     /**
      * @event Users/register {before}
      * @param {string} username
      * @param {string|array} identifier
      * @param {string} icon
      * @param {string} provider
      * @return {Users_User}
      */
     $return = Q::event('Users/register', compact('username', 'identifier', 'icon', 'provider', 'options'), 'before');
     if (isset($return)) {
         return $return;
     }
     $during = 'register';
     if (is_array($identifier)) {
         reset($identifier);
         switch (key($identifier)) {
             case 'device':
                 $fields = array('deviceId', 'platform', 'version');
                 Q_Valid::requireFields($fields, $identifier, true);
                 $device = $identifier;
                 if (isset($identifier['identifier'])) {
                     $identifier = $identifier['identifier'];
                 }
                 break;
             default:
                 throw new Q_Exception_WrongType(array('field' => 'identifier', 'type' => 'an array with entry named "device"'));
         }
     }
     if (Q_Valid::email($identifier, $emailAddress)) {
         $ui_identifier = $emailAddress;
         $key = 'email address';
         $type = 'email';
     } else {
         if (Q_Valid::phone($identifier, $mobileNumber)) {
             $key = 'mobile number';
             $ui_identifier = $mobileNumber;
             $type = 'mobile';
         } else {
             throw new Q_Exception_WrongType(array('field' => 'identifier', 'type' => 'email address or mobile number'), array('emailAddress', 'mobileNumber'));
         }
     }
     $user = false;
     if ($provider) {
         if ($provider != 'facebook') {
             throw new Q_Exception_WrongType(array('field' => 'provider', 'type' => '"facebook"'));
         }
         $facebook = Users::facebook();
         if ($facebook) {
             $uid = $facebook->getUser();
             try {
                 // authenticate (and possibly adopt) an existing provider user
                 // or insert a new user during this authentication
                 $user = Users::authenticate($provider, null, $authenticated, true);
             } catch (Exception $e) {
             }
             if ($user) {
                 // the user is also logged in
                 $adopted = true;
                 // Adopt this provider user
                 /**
                  * @event Users/adoptFutureUser {before}
                  * @param {Users_User} user
                  * @param {string} during
                  * @return {Users_User}
                  */
                 $ret = Q::event('Users/adoptFutureUser', compact('user', 'during'), 'before');
                 if ($ret) {
                     $user = $ret;
                 }
             }
         }
     }
     if (!$user) {
         $user = new Users_User();
         // the user we will save in the database
//.........这里部分代码省略.........
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:101,代码来源:Users.php

示例10: accountStatus

 /**
  * Get the status of the logged-in user and their account.
  * @param Users_Email $email
  *  Optional. Pass a reference here to be filled with the email object, if it's loaded.
  *  You can use it in conjunction with the "verify email" status.
  * @return array|boolean
  *  Returns false if the user is not logged in.
  *  Returns true if everything is complete.
  *  Otherwise, returns an array whose keys are the names of the missing fields:
  *  ("first_name", "last_name", "birthday", "gender", "desired_gender", "username",
  *  "email_address")
  *  and the values are "missing" or "unverified"
  */
 static function accountStatus(&$email = null)
 {
     $module = Pie_Dispatcher::uri()->module;
     $user = Users::loggedInUser();
     if (!$user) {
         // Try to authenticate
         $app_id = Pie_Config::expect('users', 'facebookApps', $module, 'appId');
         $user = Users::authenticate('facebook', $app_id);
         if (!$user) {
             return false;
         }
     }
     $result = array();
     if (empty($user->email_address)) {
         // An email address isn't verified for this user yet.
         // If the user hasn't even added an email address, then ask for one.
         if (!isset(self::$email)) {
             self::$email = new Users_Email();
             self::$email->user_id = $user->id;
             self::$email = self::$email->retrieve(null, false, '*', true)->orderBy('time_created', false)->resume();
         }
         $email = self::$email;
         if ($email) {
             // The email could be unverified, sunspended, unsubscribed, etc.
             $result['email_address'] = $email->state;
         } else {
             $result['email_address'] = 'missing';
         }
     }
     $fieldnames = array('first_name', 'last_name', 'username', 'birthday', 'gender', 'desired_gender', 'relationship_status', 'relationship_user_id', 'zipcode');
     foreach ($fieldnames as $k => $v) {
         if (empty($user->{$v})) {
             $result[$v] = 'missing';
         }
     }
     return $result;
 }
开发者ID:EGreg,项目名称:PHP-On-Pie,代码行数:50,代码来源:Users.php

示例11: items_addPhoto_response_content

function items_addPhoto_response_content()
{
    if (isset($_POST['fb_sig_app_id'])) {
        $app_id = $_POST['fb_sig_app_id'];
    } else {
        $app = Pie_Config::expect('pie', 'app');
        $app_id = Pie_Config::expect('users', 'facebookApps', $app, 'appId');
    }
    Users::authenticate('facebook', $app_id);
    return Pie::tool('items/addPhoto', array());
}
开发者ID:EGreg,项目名称:PHP-On-Pie,代码行数:11,代码来源:addPhoto.php


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