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


PHP UsersPeer::getUser方法代碼示例

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


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

示例1: executeLogin

 /**
  * Sign In form.
  * 
  * @return 
  */
 public function executeLogin($request)
 {
     if ($request->getMethod() != coreRequest::POST) {
         // get the referer option from redirectToLogin()
         $referer = $this->getUser()->getAttribute('login_referer', '');
         // get other options from redirectToLogin()
         $username = $this->getUser()->getAttribute('login_username', '');
         // clear redirectToLogin() options
         $this->getUser()->getAttributeHolder()->remove('login_referer');
         $this->getUser()->getAttributeHolder()->remove('login_username');
         $this->getRequest()->setParameter('referer', empty($referer) ? '@homepage' : $referer);
         $this->getRequest()->setParameter('username', $username);
         // AUTO FILL FORM (DEVELOPMENT ONLY!)
         if (CORE_ENVIRONMENT === 'dev') {
             $request->getParameterHolder()->add(array('username' => 'guest', 'password' => ''));
         }
     } else {
         $validator = new coreValidator($this->getActionName());
         if ($validator->validate($request->getParameterHolder()->getAll())) {
             $username = trim($request->getParameter('username'));
             $raw_password = trim($request->getParameter('password'));
             $rememberme = $request->hasParameter('rememberme');
             // check that user exists and password matches
             $user = UsersPeer::getUser($username);
             if (!$user || $this->getUser()->getSaltyHashedPassword($raw_password) != $user['password']) {
                 $request->setError('login_invalid', "Invalid username and/or password.");
                 return;
             }
             // sign in user
             $this->getUser()->signIn($user);
             // optionally, create the remember me cookie
             if ($rememberme) {
                 $this->getUser()->setRememberMeCookie($user['username'], $this->getUser()->getSaltyHashedPassword($raw_password));
             }
             // authenticate user on the community forums
             if (coreContext::getInstance()->getConfiguration()->getEnvironment() !== 'staging' && coreConfig::get('app_path_to_punbb') !== null) {
                 PunBBUsersPeer::signIn($username, $raw_password, $rememberme);
             }
             // succesfully signed in
             return $this->redirect($this->getRequestParameter('referer', '@homepage'));
         }
     }
 }
開發者ID:nikitakit,項目名稱:RevTK,代碼行數:48,代碼來源:actions.php

示例2: initialize

 /**
  * 
  */
 public function initialize(coreSessionStorage $storage, $options = array())
 {
     parent::initialize($storage, $options);
     // sign in unauthenticated user if a "remember me" cookie exists
     if (!$this->isAuthenticated()) {
         if ($cookieData = coreContext::getInstance()->getRequest()->getCookie(self::COOKIE_NAME)) {
             $value = unserialize(base64_decode($cookieData));
             $username = $value[0];
             $saltyPassword = $value[1];
             // sign in user if user is valid and password from cookie matches the one in database
             $user = UsersPeer::getUser($username);
             if ($user && $saltyPassword == $user['password']) {
                 $this->signIn($user);
             }
         }
     }
     // session duration preferences
     $this->localPrefs = new LocalPrefs($this);
 }
開發者ID:krisodb,項目名稱:RevTK,代碼行數:22,代碼來源:rtkUser.php

示例3: executeIndex

 public function executeIndex($request)
 {
     $username = $request->getParameter('username');
     if (!$username) {
         if ($this->getUser()->isAuthenticated()) {
             $username = $this->getUser()->getUserName();
         } else {
             // if unauthenticated user checks his (bookmarked?) profile, go to login and back
             $url = $this->getController()->genUrl('profile/index', true);
             $this->getUser()->redirectToLogin(array('referer' => $url));
         }
     }
     if ($user = UsersPeer::getUser($username)) {
         $this->user = $user;
         $this->self_account = $user['username'] == $this->getUser()->getUserName();
         $this->kanji_count = ReviewsPeer::getReviewedFlashcardCount($user['userid']);
         $this->total_reviews = ReviewsPeer::getTotalReviews($user['userid']);
         $this->forum_uid = coreConfig::get('app_path_to_punbb') !== null ? PunBBUsersPeer::getInstance()->getForumUID($username) : false;
         return coreView::SUCCESS;
     }
     return coreView::ERROR;
 }
開發者ID:nikitakit,項目名稱:RevTK,代碼行數:22,代碼來源:actions.php

示例4: executeRequestPassword

 /**
  * Forgot Password page.
  * 
  * Request the username, send an email tot the corresponding
  * email address, with a new password.
  *
  */
 public function executeRequestPassword($request)
 {
     if ($request->getMethod() != coreRequest::POST) {
         return coreView::SUCCESS;
     }
     // handle the form submission
     $validator = new coreValidator($this->getActionName());
     if ($validator->validate($request->getParameterHolder()->getAll())) {
         $username = trim($request->getParameter('username'));
         $user = UsersPeer::getUser($username);
         if ($user) {
             // set new random password
             $raw_password = strtoupper(substr(md5(rand(100000, 999999)), 0, 8));
             // update the password on main site and forum
             $this->getUser()->changePassword($user['username'], $raw_password);
             // send email with new password, user username from db here to email user with the
             // username in the exact CaSe they registered with
             $mailer = new rtkMail();
             $mailer->sendRequestPasswordConfirmation($user['email'], $user['username'], $raw_password);
             return 'MailSent';
         } else {
             $request->setError('username_invalid', 'This username could not be found. Did you spell your username correctly?');
             return coreView::SUCCESS;
         }
     }
 }
開發者ID:kc5nra,項目名稱:RevTK,代碼行數:33,代碼來源:actions.php


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