本文整理汇总了PHP中Token::byToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::byToken方法的具体用法?PHP Token::byToken怎么用?PHP Token::byToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::byToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logout
public function logout()
{
if (User::isLoggedIn()) {
Activity::log("logged out.");
//remove our token, if we got one.
if ($_COOKIE['token']) {
$data = unserialize(base64_decode($_COOKIE['token']));
$token = Token::byToken($data['token']);
$token->delete();
}
//unset specific variables.
setcookie('token', '', time() - 420000, '/', SITE_HOSTNAME, FORCE_SSL, true);
unset($_SESSION['userid']);
//nuke the session.
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time() - 420000, '/', SITE_HOSTNAME, FORCE_SSL, true);
}
session_unset();
session_destroy();
$this->forwardToUrl("/");
}
}
示例2: checkToken
public function checkToken($t)
{
$token = Token::byToken($t);
if ($token->isHydrated() && $token->get('user_id') == $this->id) {
return true;
} else {
return false;
}
}
示例3: loginandregister
public function loginandregister()
{
$this->setTitle('Login or register a new account.');
//did we get a redirect payload or anything?
if ($this->args('payload')) {
$payload = unserialize(base64_decode($this->args('payload')));
if (is_array($payload) && $payload['type'] && $payload['data']) {
$_SESSION['payload'] = $payload;
}
}
//did we get a token?
if ($this->args('token')) {
//try to login with it.
User::loginWithToken($this->args('token'));
if (User::isLoggedIn()) {
//fully log them in.
$data = unserialize(base64_decode($this->args('token')));
$token = Token::byToken($data['token']);
$token->setCookie();
//to our dashboard
$this->forwardToUrl("/");
}
}
}