- $para = $body->appendElement('p', sprintf(_('Sign in to %s using…'), $domain_name));
- $para->setAttribute('class', 'signinwelcome');
- $form = $body->appendForm('', 'POST', 'authform');
- $form->setAttribute('id', 'authform');
- $form->setAttribute('class', 'loginarea');
- $ulist = $form->appendElement('ul');
- $ulist->setAttribute('class', 'flat emaillist');
- $emails = $utils->getGroupedEmails($user['group_id']);
- if (!count($emails)) { $emails = array($user['email']); }
- foreach ($emails as $email) {
- $litem = $ulist->appendElement('li');
- $litem->appendInputRadio('user_email', 'uemail_'.md5($email), $email, $email == $user['email']);
- $litem->appendLabel('uemail_'.md5($email), $email);
+ // If the referrer is from the auth system and we have a different domain to redirect to,
+ // we can safely assume we just logged in with that email and skip the interstitial page.
+ $refer_domain = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
+ if (is_null($is_authorized) && ($refer_domain == $_SERVER['SERVER_NAME']) && ($refer_domain != $domain_name) &&
+ (dirname($_SERVER['REQUEST_URI']) == dirname(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH)))) {
+ $is_authorized = true;
+ }
+ if (is_null($is_authorized)) {
+ $para = $body->appendElement('p', sprintf(_('Sign in to %s using…'), $domain_name));
+ $para->setAttribute('class', 'signinwelcome');
+ $form = $body->appendForm('', 'POST', 'authform');
+ $form->setAttribute('id', 'authform');
+ $form->setAttribute('class', 'loginarea');
+ $ulist = $form->appendElement('ul');
+ $ulist->setAttribute('class', 'flat emaillist');
+ $emails = $utils->getGroupedEmails($user['group_id']);
+ if (!count($emails)) { $emails = array($user['email']); }
+ foreach ($emails as $email) {
+ $litem = $ulist->appendElement('li');
+ $litem->appendInputRadio('user_email', 'uemail_'.md5($email), $email, $email == $user['email']);
+ $litem->appendLabel('uemail_'.md5($email), $email);
+ }
+ $para = $form->appendElement('p');
+ $para->setAttribute('class', 'small otheremaillinks');
+ $link = $para->appendLink('#', _('Add another email address'));
+ $link->setAttribute('id', 'addanotheremail'); // Makes the JS put the right functionality onto the link.
+ $para->appendText(' ');
+ $link = $para->appendLink('#', _('This is not me'));
+ $link->setAttribute('id', 'isnotme'); // Makes the JS put the right functionality onto the link.
+ $authinput = $form->appendInputHidden('authorized', 'yes');
+ $authinput->setAttribute('id', 'isauthorized');
+ $submit = $form->appendInputSubmit(_('Sign in'));
+ $para = $form->appendElement('p');
+ $para->setAttribute('class', 'small');
+ $link = $para->appendLink('#', _('Cancel'));
+ $link->setAttribute('id', 'cancelauth'); // Makes the JS put the right functionality onto the link.
+ $utils->setRedirect($session, $_SERVER['REQUEST_URI']);