Skip to content

Commit

Permalink
Issue #2619262 by epicflux, snufkin: Allow Modules to Alter $gotourl …
Browse files Browse the repository at this point in the history
…on User Logout
  • Loading branch information
snufkin authored and Balazs Dianiska committed Jul 21, 2016
1 parent 6e92be6 commit 67a7f17
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
36 changes: 36 additions & 0 deletions simplesamlphp_auth.api.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,39 @@ function hook_simplesamlphp_auth_pre_login($attributes, $ext_user) {
exit();
}
}

/**
* Allow modules to change the url passed to simplesamlphp during logout.
*
* Called when a user logs out of Drupal.
*
* @param string $gotourl
* The url to be passed to simplesamlphp.
* @param object $account
* The user being logged out.
*/
function hook_simplesamlphp_auth_logout_gotourl_alter(&$gotourl, $account) {
// Example of reacting to a value on the account.
if ($account->field_example == 'example_value') {
$gotourl = url(
'thanks-for-stopping-by',
array(
'absolute' => TRUE,
)
);
}

// Example of adding the destination value to the redirect URL.
if (isset($_GET['destination'])) {
// Ensure our redirect URL is absolute.
$redirect_url = url(
$_GET['destination'],
array(
'absolute' => TRUE,
)
);

// Add our redirect URL as a querystring to the full URL.
$gotourl = $gotourl . '?redirect=' . drupal_encode_path($redirect_url);
}
}
3 changes: 3 additions & 0 deletions simplesamlphp_auth.module
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ function simplesamlphp_auth_user_logout($account) {
$gotourl = variable_get('simplesamlphp_auth_logoutgotourl', '');
}

// Allow modules to alter $gotourl.
drupal_alter('simplesamlphp_auth_logout_gotourl', $gotourl, $account);

$_simplesamlphp_auth_as->logout($gotourl);

}
Expand Down

0 comments on commit 67a7f17

Please sign in to comment.