summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/consumer/finish_auth.php38
-rw-r--r--examples/consumer/try_auth.php10
2 files changed, 18 insertions, 30 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';
diff --git a/examples/consumer/try_auth.php b/examples/consumer/try_auth.php
index 6aa6fd1..7f1355f 100644
--- a/examples/consumer/try_auth.php
+++ b/examples/consumer/try_auth.php
@@ -21,10 +21,10 @@ $trust_root = sprintf("http://%s%s",
dirname($_SERVER['PHP_SELF']));
// Begin the OpenID authentication process.
-list($status, $info) = @$consumer->beginAuth($openid);
+$auth_request = $consumer->begin($openid);
// Handle failure status return values.
-if ($status != Auth_OpenID_SUCCESS) {
+if (!$auth_request) {
$error = "Authentication error.";
include 'index.php';
exit(0);
@@ -32,9 +32,9 @@ if ($status != Auth_OpenID_SUCCESS) {
// Redirect the user to the OpenID server for authentication. Store
// the token for this authentication so we can verify the response.
-$_SESSION['openid_token'] = $info->token;
-$redirect_url = @$consumer->constructRedirect($info, $process_url,
- $trust_root);
+
+$redirect_url = $auth_request->redirectURL($trust_root,
+ $process_url);
header("Location: ".$redirect_url);