本文整理汇总了PHP中Token::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::delete方法的具体用法?PHP Token::delete怎么用?PHP Token::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::delete方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: auth
public function auth()
{
$client_id = $this->input->get('clent_id');
$application = new Application();
$application->client_id = $client_id;
$application->get();
if (!$application->exists()) {
$data['title'] = 'Auth Page';
$data['content'] = 'oauth/noapplication';
$this->load->view('master', $data);
} elseif (!$this->user_id) {
$redirect = 'users/login?redirect_url=oauth/auth?client_id=' . $application->id;
redirect($redirect);
} elseif ($this->input->post()) {
$allow = $this->input->post('allow');
if ($allow) {
$user = new User($this->user_id);
$existing_token = new Token();
$existing_token->where('user_id', $user->id);
$existing_token->where('application_id', $application->id);
$existing_token->get();
if ($existing_token->exists()) {
$existing_token->delete();
}
$token = $this->generate_token();
$token->save(array($application, $user));
die;
echo 'here';
}
} else {
$this->load->helper('form');
$data['application'] = array('id' => $application->id, 'name' => $application->name, 'client_id' => $application->client_id, 'client_secret' => $application->client_secret, 'redirect_url' => $application->redirect_url);
$data['title'] = 'Auth Page';
$data['content'] = 'oauth/authorize';
$this->load->view('master', $data);
}
}
示例2: testDelete
function testDelete()
{
$patron_id = 1;
$menu_id = 2;
$sender_id = 3;
$test_token = new Token($patron_id, $menu_id, $sender_id);
$test_token->save();
$patron_id2 = 4;
$menu_id2 = 5;
$sender_id2 = 6;
$test_token2 = new Token($patron_id2, $menu_id2, $sender_id2);
$test_token2->save();
$test_token->delete();
$result = Token::getAll();
$this->assertEquals([$test_token2], $result);
}
示例3: revoke_token
/**
* Revoke specified OAuth token
*
* Revokes the authorization token specified by $token_key.
* Throws exceptions in case of error.
*
* @param string $token_key The token to be revoked
*
* @access public
**/
public function revoke_token($token_key)
{
$rt = new Token();
$rt->tok = $token_key;
$rt->type = 0;
$rt->state = 0;
if (!$rt->find(true)) {
throw new Exception('Tried to revoke unknown token');
}
if (!$rt->delete()) {
throw new Exception('Failed to delete revoked token');
}
}
示例4: revoke_token
/**
* Revoke specified access token
*
* Revokes the token specified by $token_key.
* Throws exceptions in case of error.
*
* @param string $token_key the token to be revoked
* @param int $type type of token (0 = req, 1 = access)
*
* @access public
*
* @return void
*/
public function revoke_token($token_key, $type = 0)
{
$rt = new Token();
$rt->tok = $token_key;
$rt->type = $type;
$rt->state = 0;
if (!$rt->find(true)) {
// TRANS: Exception thrown when an attempt is made to revoke an unknown token.
throw new Exception(_('Tried to revoke unknown token.'));
}
if (!$rt->delete()) {
// TRANS: Exception thrown when an attempt is made to remove a revoked token.
throw new Exception(_('Failed to delete revoked token.'));
}
}
示例5: Token
function _deleteTokens()
{
$token = new Token();
$token->consumer_key = $this->consumer_key;
$token->delete();
}
示例6: cancel
/**
* Cancel a subscription
*
*/
function cancel($subscriber, $other)
{
if (!self::exists($subscriber, $other)) {
throw new Exception(_('Not subscribed!'));
}
// Don't allow deleting self subs
if ($subscriber->id == $other->id) {
throw new Exception(_('Couldn\'t delete self-subscription.'));
}
if (Event::handle('StartUnsubscribe', array($subscriber, $other))) {
$sub = Subscription::pkeyGet(array('subscriber' => $subscriber->id, 'subscribed' => $other->id));
// note we checked for existence above
assert(!empty($sub));
// @todo: move this block to EndSubscribe handler for
// OMB plugin when it exists.
if (!empty($sub->token)) {
$token = new Token();
$token->tok = $sub->token;
if ($token->find(true)) {
$result = $token->delete();
if (!$result) {
common_log_db_error($token, 'DELETE', __FILE__);
throw new Exception(_('Couldn\'t delete subscription OMB token.'));
}
} else {
common_log(LOG_ERR, "Couldn't find credentials with token {$token->tok}");
}
}
$result = $sub->delete();
if (!$result) {
common_log_db_error($sub, 'DELETE', __FILE__);
throw new Exception(_('Couldn\'t delete subscription.'));
}
self::blow('user:notices_with_friends:%d', $subscriber->id);
$subscriber->blowSubscriptionsCount();
$other->blowSubscribersCount();
Event::handle('EndUnsubscribe', array($subscriber, $other));
}
return;
}
示例7: onEndUnsubscribe
/**
* Remove old OMB subscription tokens
*
* @param User $user subscriber
* @param Profile $other subscribee
* @return hook return value
*/
function onEndUnsubscribe($profile, $other)
{
$sub = Subscription::pkeyGet(array('subscriber' => $subscriber->id, 'subscribed' => $other->id));
if (!empty($sub->token)) {
$token = new Token();
$token->tok = $sub->token;
if ($token->find(true)) {
$result = $token->delete();
if (!$result) {
common_log_db_error($token, 'DELETE', __FILE__);
throw new Exception(_m('Could not delete subscription OMB token.'));
}
} else {
common_log(LOG_ERR, "Couldn't find credentials with token {$token->tok}", __FILE__);
}
}
return true;
}
示例8: delete_update_token
private function delete_update_token()
{
$this->token->delete();
}
示例9: logout_post
/**
* Account logout
* @param token
* @return object{status}
*/
public function logout_post()
{
$response = new stdClass();
$token_entry = new Token();
$token_entry->get_by_valid_token($this->post('token'))->get();
if ($token_entry->exists()) {
$token_entry->delete();
$response->status = true;
} else {
$response->status = false;
$response->error = 'Token not found or session expired';
}
$this->response($response);
}
示例10: testTokensDelete
/**
* @group ecommerce
* @group 3dsecure
* @expectedException Everypay\Exception\RuntimeException
* @expectedExceptionMessage Resource Tokens does not support method Everypay\Token::delete
*/
public function testTokensDelete()
{
//applicable both in local and remote mode
$token = 'ctn_oLyYPaymB2AozoABZYYHnb3g';
$payment = Token::delete($token);
}
示例11: xhtmlForm
throw new \Exception('token dont exist');
}
if ($session->id && $user_id != $session->id) {
throw new \Exception('HACKER stop doing that!');
}
if ($session->id) {
echo '<div class="critical">You are already logged in! Are you sure you want to reset your password?</div>';
}
if (isset($_POST['reset_pwd']) && isset($_POST['reset_pwd2'])) {
/// TODO reuse code from register user
if ($_POST['reset_pwd'] == $_POST['reset_pwd2']) {
UserHandler::setPassword($user_id, $_POST['reset_pwd']);
$session->login($user->name, $_POST['reset_pwd']);
echo '<div class="okay">Your password has been reset. You have been logged in.</div>';
// delete consumed token
Token::delete($user_id, 'activation_code');
return;
} else {
$error->add('The passwords dont match');
}
}
echo $error->render(true);
echo 'Reset password for user <b>' . $user->name . '</b>';
$header->registerJsFunction('function validate_reset_pwd_form(frm)' . '{' . 'if (!frm.reset_pwd.value||!frm.reset_pwd2.value)' . 'return false;' . 'return true;' . '}');
//XXXX use XhtmlForm class, it needs a way to show the images first
echo xhtmlForm('reg_frm', '', '', '', 'return validate_reset_pwd_form(this);');
echo '<table cellpadding="2">';
echo '<tr><td>' . t('New password') . ':</td>' . '<td>' . xhtmlPassword('reset_pwd') . ' ' . xhtmlImage($page->getRelativeCoreDevUrl() . 'gfx/icon_keys.png', t('Password')) . '</td>' . '</tr>';
echo '<tr><td>' . t('Again') . ':</td>' . '<td>' . xhtmlPassword('reset_pwd2') . ' ' . xhtmlImage($page->getRelativeCoreDevUrl() . 'gfx/icon_keys.png', t('Repeat password')) . '</td>' . '</tr>';
echo '</table><br/>';
echo xhtmlSubmit('Reset password', 'button', 'font-weight:bold');
示例12: testTokensDelete
/**
* @expectedException Everypay\Exception\RuntimeException
* @expectedExceptionMessage Resource Tokens does not support method Everypay\Token::delete
*/
public function testTokensDelete()
{
$token = 'ctn_oLyYPaymB2AozoABZYYHnb3g';
$payment = Token::delete($token);
}