summaryrefslogtreecommitdiffstats
path: root/examples/consumer/finish_auth.php
diff options
context:
space:
mode:
Diffstat (limited to 'examples/consumer/finish_auth.php')
-rw-r--r--examples/consumer/finish_auth.php38
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';