@@ -15,15 +15,17 @@ With the following PHP code below, you can display a log in button that, when cl
1515use Authwave\Authenticator;
1616require __DIR__ . "/vendor/autoload.php";
1717
18- // This constant can be loaded from your application's configuration
19- // or environment variables. They are supplied by the remote Authwave provider.
18+ // These constants can be loaded from your application's configuration
19+ // or environment variables. They are created in the remote Authwave provider.
20+ define("CLIENT_ID", "my-secure-application");
2021define("CLIENT_KEY", "1234567890abcdef");
2122
2223// Construct the Authenticator class as soon as possible, as this handles the
2324// Authentication steps passed via the query string from the remote provider.
2425$auth = new Authenticator(
25- CLIENT_KEY, // See above
26- $_SERVER["REQUEST_URI"]
26+ CLIENT_ID,
27+ CLIENT_KEY,
28+ $_SERVER["REQUEST_URI"]
2729);
2830
2931// Handle authentication login/logout action via the querystring:
@@ -32,24 +34,24 @@ if(isset($_GET["login"])) {
3234// remote provider. The remote provider will in turn redirect the user agent
3335// back to the return URI (set as 3rd parameter of Authenticator's constructor),
3436// at which point the user will be considered authenticated.
35- $auth->login();
37+ $auth->login();
3638}
3739elseif(isset($_GET["logout"])) {
38- $auth->logout();
40+ $auth->logout();
3941}
4042
4143// Authentication is handled by Authwave, so you can trust "isLoggedIn"
4244// as a mechanism for protecting your sensitive information.
4345if($auth->isLoggedIn()) {
44- echo <<<HTML
45- <p >You are logged in as <strong >{$auth->getEmail()}</strong ></p >
46- <p ><a href =" ?logout" >Log out</a ></p >
47- HTML;
46+ echo <<<HTML
47+ <p >You are logged in as <strong >{$auth->getEmail()}</strong ></p >
48+ <p ><a href =" ?logout" >Log out</a ></p >
49+ HTML;
4850}
4951else {
50- echo <<<HTML
51- <p >You are not logged in!</p >
52- <p ><a href =" ?login" >Log in</a ></p >
53- HTML;
52+ echo <<<HTML
53+ <p >You are not logged in!</p >
54+ <p ><a href =" ?login" >Log in</a ></p >
55+ HTML;
5456}
5557```
0 commit comments