diff options
author | tailor <cygnus@janrain.com> | 2006-05-11 00:07:28 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2006-05-11 00:07:28 +0000 |
commit | f28e29123ee6d096b4550f44c6b4d165782270b8 (patch) | |
tree | 603592ed767a5b816e349aad32928b51fae8360b /examples/consumer/finish_auth.php | |
parent | 743d12a13f60819281151be2cf67e8fd6367cd9c (diff) | |
download | php-openid-f28e29123ee6d096b4550f44c6b4d165782270b8.zip php-openid-f28e29123ee6d096b4550f44c6b4d165782270b8.tar.gz php-openid-f28e29123ee6d096b4550f44c6b4d165782270b8.tar.bz2 |
[project @ Finished preliminary changes to consumer example]
Diffstat (limited to 'examples/consumer/finish_auth.php')
-rw-r--r-- | examples/consumer/finish_auth.php | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/examples/consumer/finish_auth.php b/examples/consumer/finish_auth.php index 1d16e2f..5d21456 100644 --- a/examples/consumer/finish_auth.php +++ b/examples/consumer/finish_auth.php @@ -3,33 +3,21 @@ require_once "common.php"; session_start(); -// Retrieve the token from the session so we can verify the server's -// response. -$token = $_SESSION['openid_token']; - // Complete the authentication process using the server's response. -list($status, $info) = $consumer->completeAuth($token, $_GET); - -$openid = null; +$response = $consumer->complete($_GET); -// React to the server's response. $info is the OpenID that was -// tried. -if ($status != Auth_OpenID_SUCCESS) { - $msg = sprintf("Verification of %s failed.", $info); -} else { - if ($info) { - // This means the authentication succeeded. - $openid = $info; - $esc_identity = htmlspecialchars($openid, ENT_QUOTES); - $success = sprintf('You have successfully verified ' . - '<a href="%s">%s</a> as your identity.', - $esc_identity, - $esc_identity - ); - } else { - // This means the authentication was cancelled. - $msg = 'Verification cancelled.'; - } +if ($response->status == Auth_OpenID_CANCEL) { + // This means the authentication was cancelled. + $msg = 'Verification cancelled.'; +} else if ($response->status == Auth_OpenID_FAILURE) { + $msg = "OpenID authentication failed: " . $response->message; +} else if ($response->status == Auth_OpenID_SUCCESS) { + // This means the authentication succeeded. + $openid = $response->identity_url; + $esc_identity = htmlspecialchars($openid, ENT_QUOTES); + $success = sprintf('You have successfully verified ' . + '<a href="%s">%s</a> as your identity.', + $esc_identity, $esc_identity); } include 'index.php'; |