function shib_auth_custom_form in Shibboleth Authentication 6.4
Same name and namespace in other branches
- 7.4 shib_auth.module \shib_auth_custom_form()
If any customization or consent option is enabled, the custom form will show up before registering and forces the user to accept user consent and define username and/or e-mail address (prefilling fields with the data coming from the IdP) @umail_single e-mail address received from IdP @uname id received from IdP
1 call to shib_auth_custom_form()
- shib_auth_init in ./
shib_auth.module - Create a new user based on informations from the Shibboleth handler if it's necessary or log in.
File
- ./
shib_auth.module, line 509 - Drupal Shibboleth authentication module.
Code
function shib_auth_custom_form($umail_single = NULL, $uname = NULL) {
if (isset($_POST['op']) && $_POST['op'] == t('Cancel')) {
shib_auth_cancel_custom();
}
//check if any of the customization options are enabled
if (shib_auth_config('enable_custom_mail') || $umail_single && shib_auth_config('define_username') || (shib_auth_config('enable_custom_mail') || $umail_single) && shib_auth_config('terms_accept')) {
// if there already is a POST-ed form, save received values as a variable
if ($_POST['form_id'] == 'shib_auth_custom_data') {
if ($_POST['custom_mail']) {
$custom_mail = $_POST['custom_mail'];
}
if ($_POST['custom_username']) {
$custom_username = $_POST['custom_username'];
}
if ($_POST['accept']) {
$consent_accepted = $_POST['accept'];
}
}
//If the consent is accepted or it isn't configured
if ($consent_accepted && shib_auth_config('terms_accept') || !shib_auth_config('terms_accept')) {
// ****** CUSTOM MAIL **********
//if the user provided the custom mail string on the custom data form, and it is not empty
if (isset($custom_mail) && $custom_mail) {
shib_auth_custom_mail($uname, $custom_username, $custom_mail);
}
elseif (shib_auth_config('define_username') && isset($custom_username) && $custom_username) {
shib_auth_custom_username($uname, $custom_username, $umail_single);
}
elseif ($consent_accepted && shib_auth_config('terms_accept')) {
//register user
shib_auth_save_authmap($uname, $uname, $umail_single);
}
else {
shib_auth_goto_custom_form();
}
}
else {
shib_auth_goto_custom_form();
}
//If everything was fine, the user is logged in, and redirected to the page, which she wanted to open before the auth process had been initiated
shib_auth_submit_redirect();
return TRUE;
}
else {
return FALSE;
}
}