本文整理汇总了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;
}
示例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);
}
示例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);
}
}