summaryrefslogtreecommitdiffstats
path: root/examples/consumer/try_auth.php
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2007-03-10 00:40:35 +0000
committertailor <cygnus@janrain.com>2007-03-10 00:40:35 +0000
commit338d0a3cc020328d349faff0c5d87a5ff6459f6e (patch)
treedded8e19bc3ff0b5035f02a73c8ab0e68ed7c361 /examples/consumer/try_auth.php
parentc3fc5ffa72ceee8aedd043e718297f50eecc4426 (diff)
downloadphp-openid-338d0a3cc020328d349faff0c5d87a5ff6459f6e.zip
php-openid-338d0a3cc020328d349faff0c5d87a5ff6459f6e.tar.gz
php-openid-338d0a3cc020328d349faff0c5d87a5ff6459f6e.tar.bz2
[project @ Comments in example consumer]
Diffstat (limited to 'examples/consumer/try_auth.php')
-rw-r--r--examples/consumer/try_auth.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/examples/consumer/try_auth.php b/examples/consumer/try_auth.php
index 97a463a..37bb35d 100644
--- a/examples/consumer/try_auth.php
+++ b/examples/consumer/try_auth.php
@@ -44,31 +44,40 @@ function run() {
// Begin the OpenID authentication process.
$auth_request = $consumer->begin($openid);
- // Handle failure status return values.
+ // No auth request means we can't begin OpenID.
if (!$auth_request) {
displayError("Authentication error; not a valid OpenID.");
}
- $auth_request->addExtensionArg('sreg', 'optional', 'email');
+ // Add an extension arg for optional Simple Registration parameters.
+ $auth_request->addExtensionArg('sreg', 'optional', 'email,postcode');
// Redirect the user to the OpenID server for authentication.
// Store the token for this authentication so we can verify the
// response.
+ // For OpenID 1, send a redirect. For OpenID 2, use a Javascript
+ // form to send a POST request to the server.
if ($auth_request->shouldSendRedirect()) {
$redirect_url = $auth_request->redirectURL(getTrustRoot(),
getReturnTo());
+ // If the redirect URL can't be built, display an error
+ // message.
if (Auth_OpenID::isFailure($redirect_url)) {
displayError("Could not redirect to server: " . $redirect_url->message);
} else {
+ // Send redirect.
header("Location: ".$redirect_url);
}
} else {
+ // Generate form markup and render it.
$form_id = 'openid_message';
$form_html = $auth_request->formMarkup(getTrustRoot(), getReturnTo(),
false, array('id' => $form_id));
+ // Display an error if the form markup couldn't be generated;
+ // otherwise, render the HTML.
if (Auth_OpenID::isFailure($form_html)) {
displayError("Could not redirect to server: " . $form_html->message);
} else {