summaryrefslogtreecommitdiffstats
path: root/examples/consumer/finish_auth.php
blob: bee57436149d112b329a0454eb32afb2f2c7f55e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

require_once "common.php";
session_start();

// Complete the authentication process using the server's response.
$response = $consumer->complete($_GET);

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);

    if ($response->endpoint->canonicalID) {
        $success .= '  (XRI CanonicalID: '.$response->endpoint->canonicalID.') ';
    }

    $sreg = $response->extensionResponse('sreg');

    if (@$sreg['email']) {
        $success .= "  You also returned '".$sreg['email']."' as your email.";
    }
    if (@$sreg['postcode']) {
        $success .= "  Your postal code is '".$sreg['postcode']."'";
    }
}

include 'index.php';

?>