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


PHP User::GetToken方法代碼示例

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


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

示例1: AuthenticatePersistent

 public function AuthenticatePersistent(\model\User $user)
 {
     // Check signature
     if (!$this->DoHashesEqual(self::Hash($user->GetUserName() . $user->GetToken()), $user->GetSignature())) {
         // Signatures does not match
         throw new \UnexpectedValueException("Signature from 'username' and 'token' does not match original 'signature'");
     }
     // Try to get specific user
     $userFromDB = $this->users->GetUserByUsername($user->GetUserName());
     if ($userFromDB) {
         // Verify token in user object against token in db table row.
         return $this->DoHashesEqual($user->GetToken(), $userFromDB->GetToken());
     }
     return false;
 }
開發者ID:johnnypesola,項目名稱:1dv608-Assignment-2,代碼行數:15,代碼來源:AuthService.php

示例2: SaveLoginOnClient

 public function SaveLoginOnClient(\model\User $user)
 {
     // Prepare values
     $cookieValues = implode(':', array($user->GetUserName(), $user->GetToken(), $user->GetSignature()));
     // Save values in cookie (expires in 30 days)
     return setcookie(self::$COOKIE_ID, $cookieValues, time() + 60 * 60 * 24 * self::$COOKIE_VALID_DAYS);
 }
開發者ID:johnnypesola,項目名稱:1dv608-php-project,代碼行數:7,代碼來源:LoginView.php

示例3: AddPersistentLogin

 public function AddPersistentLogin(\model\User $user)
 {
     try {
         // Assert that token is hashed
         assert($user->IsTokenHashed());
         // Assert that user has id
         assert(is_numeric($user->GetUserId()));
         // Prepare db statement
         $statement = self::$db->prepare('UPDATE ' . self::$DB_TABLE_NAME . ' SET `user_token_hash` = :token' . ' WHERE `user_id` = :userId');
         // Prepare input array
         $inputArray = ['userId' => $user->GetUserId(), 'token' => $user->GetToken()];
         // Execute db statement
         $statement->execute($inputArray);
         // Check if db insertion was successful
         return $statement->rowCount() == 1;
     } catch (\Exception $exception) {
         throw new \Exception(self::$DB_UPDATE_ERROR);
     }
 }
開發者ID:johnnypesola,項目名稱:1dv608-php-project,代碼行數:19,代碼來源:UserDAL.php


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