本文整理匯總了PHP中Model\User::GetSignature方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::GetSignature方法的具體用法?PHP User::GetSignature怎麽用?PHP User::GetSignature使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model\User
的用法示例。
在下文中一共展示了User::GetSignature方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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);
}
示例2: 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;
}