Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions onelogin_saml/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ function onelogin_saml_acs() {
drupal_set_message("No SAML Response found.", 'error', FALSE);
drupal_goto('');
}

/*When a user logins using OneLogin and the URL has a destination parameter in it,
* we redirect them to the page after logging in
* Works because we append destination parameter to OneLogin SAML url
*/
if(isset($_POST['RelayState'])){
drupal_goto($_POST['RelayState']);
}
drupal_goto('user/' . $user->uid);
}

Expand Down Expand Up @@ -206,7 +212,8 @@ function onelogin_saml_auth($auth) {
if ($result && $user = user_load(key($result['user']))) {
$GLOBALS['user'] = $user;
$form_state['uid'] = $user->uid;

//If a user has previously logged in, we pull the roles it already has
$roles = $user->roles;
if (!empty($roles)) {
try {
$fields = array(
Expand Down
3 changes: 2 additions & 1 deletion onelogin_saml/onelogin_saml.module
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ function _onelogin_saml_user_login_form_alter(&$form, &$form_state) {
if ($showSamlLink) {
// Add a "Log in using SAML" link to the user-login form.
$items = array();
//Pass on a destination parameter to OneLogin. The OneLogin ldp will pass it back to us using RelayState
$items[] = array(
'data' => l(t('Log in using SAML'), url('onelogin_saml/sso', array('absolute' => true)), array('external' => TRUE)),
'data' => l(t('Log in using SAML'), url('onelogin_saml/sso', array('absolute' => true)), array('external' => TRUE),array('query'=>array('destination'=>drupal_get_destination()))),
'class' => array('saml-link'),
);

Expand Down