function _securesite_dialog in Secure Site 6.2
Same name and namespace in other branches
- 7.2 securesite.inc \_securesite_dialog()
Display authentication dialog and send password reset mails.
Parameters
$type: The type of authentication dialog to display.
7 calls to _securesite_dialog()
- securesite_boot in ./
securesite.module - Implementation of hook_boot().
- securesite_user in ./
securesite.module - Implementation of hook_user().
- _securesite_403 in ./
securesite.inc - Menu callback; handle restricted pages.
- _securesite_denied in ./
securesite.inc - Deny access to users who are not authorized to access secured pages.
- _securesite_digest_auth in ./
securesite.inc - Perform digest authentication.
File
- ./
securesite.inc, line 303 - Secure Site log-in functions.
Code
function _securesite_dialog($type) {
global $base_path;
// Has the password reset form been submitted?
if (isset($_POST['form_id']) && $_POST['form_id'] == 'securesite_user_pass') {
// Get form messages, but do not display form.
drupal_get_form('securesite_user_pass');
$content = '';
}
elseif (strpos($_GET['q'], 'user/reset/') === 0 || module_exists('i18n') && i18n_selection_mode() != 'off' && strpos($_GET['q'], i18n_selection_mode('params') . '/user/reset/') === 0) {
$args = explode('/', $_GET['q']);
if (module_exists('i18n') && i18n_selection_mode() != 'off' && i18n_selection_mode('params') != '') {
// Remove the language argument.
array_shift($args);
}
// The password reset function doesn't work well if it doesn't have all the
// required parameters or if the UID parameter isn't valid
if (count($args) < 5 || user_load(array(
'uid' => $args[2],
'status' => 1,
)) == FALSE) {
$error = t('You have tried to use an invalid one-time log-in link.');
$reset = variable_get('securesite_reset_form', t('Enter your user name or e-mail address.'));
if (empty($reset)) {
drupal_set_message($error, 'error');
$content = '';
}
else {
$error .= ' ' . t('Please request a new one using the form below.');
drupal_set_message($error, 'error');
$content = drupal_get_form('securesite_user_pass');
}
}
}
elseif (!module_exists('openid') || $_GET['q'] != 'openid/authenticate') {
// Display log-in dialog.
switch ($type) {
case SECURESITE_DIGEST:
$header = _securesite_digest_validate($status);
if (empty($header)) {
$realm = variable_get('securesite_realm', variable_get('site_name', 'Drupal'));
$header = _securesite_digest_validate($status, array(
'realm' => $realm,
'fakerealm' => _securesite_fake_realm(),
));
}
if (strpos($header, 'WWW-Authenticate') === 0) {
drupal_set_header($header);
drupal_set_header('HTTP/1.1 401 Unauthorized');
}
else {
drupal_set_header($header);
}
break;
case SECURESITE_BASIC:
drupal_set_header('WWW-Authenticate: Basic realm="' . _securesite_fake_realm() . '"');
drupal_set_header('HTTP/1.1 401 Unauthorized');
break;
case SECURESITE_FORM:
drupal_set_header('HTTP/1.1 200 OK');
break;
}
// Form authentication doesn't work for cron, so allow cron.php to run
// without authenticating when no other authentication type is enabled.
if (request_uri() != $base_path . 'cron.php' || variable_get('securesite_type', array(
SECURESITE_BASIC,
)) != array(
SECURESITE_FORM,
)) {
drupal_set_title(t('Authentication required'));
$content = _securesite_dialog_page();
}
}
if (isset($content)) {
print theme('securesite_page', $content);
module_invoke_all('exit');
exit;
}
}