friendship ended with social-app. php is my new best friend

implement rest of grant flow

Changed files
+6 -3
templates
_partials
+4 -2
index.php
···
Flight::set('publicApi', PUBLIC_API);
Flight::set('frontpageFeed', FRONTPAGE_FEED);
Flight::set('defaultRelay', DEFAULT_RELAY);
-
Flight::set('userAuth', null);
Flight::set('flight.log_errors', false);
Flight::set('flight.handle_errors', false);
Flight::set('flight.content_length', false);
···
$token = $provider->getAccessToken($_GET['code'], $_GET['state']);
$storage = new SessionStorage($options);
$storage->storeAccessToken($token, $name);
-
header('Location: https://'.SITE_DOMAIN);
die(1);
} else if (isset($_GET['granted']) && $_GET['granted'] === $name) {
die(1);
} else if (isset($_GET['error'])) {
die(1);
···
Flight::set('publicApi', PUBLIC_API);
Flight::set('frontpageFeed', FRONTPAGE_FEED);
Flight::set('defaultRelay', DEFAULT_RELAY);
+
Flight::set('userAuth', $_SESSION['sbs_'.SITE_DOMAIN]);
Flight::set('flight.log_errors', false);
Flight::set('flight.handle_errors', false);
Flight::set('flight.content_length', false);
···
$token = $provider->getAccessToken($_GET['code'], $_GET['state']);
$storage = new SessionStorage($options);
$storage->storeAccessToken($token, $name);
+
header('Location: ?granted='.$name);
die(1);
} else if (isset($_GET['granted']) && $_GET['granted'] === $name) {
+
$tokenJSON = $provider->getAccessTokenFromStorage()->toJSON();
+
header('Location: https://'.SITE_DOMAIN);
die(1);
} else if (isset($_GET['error'])) {
die(1);
+2 -1
templates/_partials/nav.latte
···
<nav>
<ul>
{if $userAuth}
<li><a href="/settings">settings</a></li>
-
<li><a href="#">log out</a></li>
{else}
<li><a href="/createaccount">create</a></li>
<li><a href="/login">log in</a></li>
···
<nav>
<ul>
{if $userAuth}
+
<li><a href="/">profile</a></li>
<li><a href="/settings">settings</a></li>
+
<li><a href="/logout">log out</a></li>
{else}
<li><a href="/createaccount">create</a></li>
<li><a href="/login">log in</a></li>