You are here

public static function Client::redirect in OAuth2 Client 7.2

Same name and namespace in other branches
  1. 7 oauth2_client.inc \OAuth2\Client::redirect()

Redirect to the original path.

Redirects are registered with OAuth2\Client::setRedirect() The redirect contains the url to go to and the parameters to be sent to it.

2 calls to Client::redirect()
Client::getAccessToken in src/Client.php
Get and return an access token.
oauth2_client_authorized in ./oauth2_client.module
Callback for path oauth2/authorized.

File

src/Client.php, line 400
Class OAuth2\Client.

Class

Client
The class OAuth2\Client is used to communicate with an oauth2 server.

Namespace

OAuth2

Code

public static function redirect($clean = TRUE) {
  if (!isset($_REQUEST['state'])) {
    return;
  }
  $state = $_REQUEST['state'];
  if (!isset($_SESSION['oauth2_client']['redirect'][$state])) {
    return;
  }
  $redirect = $_SESSION['oauth2_client']['redirect'][$state];

  // We don't expect a 'destination' query argument coming from the oauth2 server.
  // This would confuse and misguide the function drupal_goto() that is called below.
  if (isset($_GET['destination'])) {
    unset($_GET['destination']);
  }
  if ($redirect['client'] !== 'oauth2_client') {
    unset($_SESSION['oauth2_client']['redirect'][$state]);
  }
  else {
    if ($clean) {
      unset($_SESSION['oauth2_client']['redirect'][$state]);
      unset($_REQUEST['code']);
      unset($_REQUEST['state']);
    }
  }
  unset($_REQUEST['q']);
  drupal_goto($redirect['uri'], array(
    'query' => $redirect['params'] + $_REQUEST,
  ));
}