diff options
-rw-r--r-- | Auth/OpenID/Consumer.php | 15 | ||||
-rw-r--r-- | examples/consumer/try_auth.php | 22 |
2 files changed, 31 insertions, 6 deletions
diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php index f5e5f3a..afb8350 100644 --- a/Auth/OpenID/Consumer.php +++ b/Auth/OpenID/Consumer.php @@ -1551,15 +1551,19 @@ class Auth_OpenID_AuthRequest { // raise ValueError( // '"return_to" is mandatory when //using "checkid_immediate"') - return null; + return new Auth_OpenID_FailureResponse(null, + "'return_to' is mandatory when using checkid_immediate"); } else if ($this->message->isOpenID1()) { // raise ValueError('"return_to" is // mandatory for OpenID 1 requests') - return null; + return new Auth_OpenID_FailureResponse(null, + "'return_to' is mandatory for OpenID 1 requests"); } else if ($this->return_to_args) { // raise ValueError('extra "return_to" arguments // were specified, but no return_to was specified') - return null; + return new Auth_OpenID_FailureResponse(null, + "extra 'return_to' arguments where specified, " . + "but no return_to was specified"); } if ($immediate) { @@ -1630,6 +1634,11 @@ class Auth_OpenID_AuthRequest { $form_tag_attrs=null) { $message = $this->getMessage($realm, $return_to, $immediate); + + if (is_a($message, 'Auth_OpenID_FailureResponse')) { + return $message; + } + return $message->toFormMarkup($this->endpoint->server_url, $form_tag_attrs); } diff --git a/examples/consumer/try_auth.php b/examples/consumer/try_auth.php index 464dd1f..b53f3cb 100644 --- a/examples/consumer/try_auth.php +++ b/examples/consumer/try_auth.php @@ -40,9 +40,25 @@ $auth_request->addExtensionArg('sreg', 'optional', 'email'); // Redirect the user to the OpenID server for authentication. Store // the token for this authentication so we can verify the response. -$redirect_url = $auth_request->redirectURL($trust_root, - $process_url); +if ($auth_request->shouldSendRedirect()) { + $redirect_url = $auth_request->redirectURL($trust_root, + $process_url); + header("Location: ".$redirect_url); +} else { + $form_id = 'openid_message'; + $form_html = $auth_request->formMarkup($trust_root, $process_url, false, + $form_tag_attrs=array('id' => $form_id)); -header("Location: ".$redirect_url); + if (is_a($form_html, 'Auth_OpenID_FailureResponse')) { + print "Error: " . $form_html->message; + } + +?> +<html><head><title>OpenID transaction in progress</title></head> +<body onload='document.getElementById("<?=$form_id?>").submit()'> +<?=$form_html?> +</body></html> +<? +} ?>
\ No newline at end of file |