diff --git a/pubcookie.install b/pubcookie.install new file mode 100644 index 0000000..2fca578 --- /dev/null +++ b/pubcookie.install @@ -0,0 +1,14 @@ + diff --git a/pubcookie.module b/pubcookie.module index bb5a953..037017b 100644 --- a/pubcookie.module +++ b/pubcookie.module @@ -47,7 +47,7 @@ function pubcookie_page() { global $pubcookie_domain; if ($user->uid) { - print theme('page', t('You are already logged in.')); + drupal_goto(); return; } @@ -114,11 +109,17 @@ function pubcookie_page() { if (PUBCOOKIE_VERBOSE_LOGGING) { watchdog('pubcookie', "uid of authenticated user is '%uid'", array('%uid' => $user->uid)); } - global $base_url; - $url = variable_get('pubcookie_success_url', $base_url); - - header('Location: '. $url); - exit(); + if (isset($_GET['destination'])) { + drupal_goto($_GET['destination']); + exit(); + } else { + global $base_url; + $url = variable_get('pubcookie_success_url', $base_url); + + if (empty($url)) { $url = base_path(); } + header('Location: '. $url); + exit(); + } } drupal_set_message(t('Pubcookie login failed.'), 'error'); @@ -235,7 +242,12 @@ function pubcookie_theme() { * Theme function for pubcookie login link. */ function theme_pubcookie_login() { - return l('Log in', pubcookie_login_link()); + $url = variable_get('pubcookie_success_url', ''); + if (empty($url)) { + $options = array('query' => array('destination' => + drupal_get_path_alias($_GET['q']))); + } else { $options = array(); } + return l('Log in', pubcookie_login_link(), $options); } /*