Started putting default templates together
This commit is contained in:
parent
825ec1c0e5
commit
7442da1ae9
@ -60,7 +60,9 @@ class Server {
|
|||||||
'logger' => null,
|
'logger' => null,
|
||||||
'callbacks' => [
|
'callbacks' => [
|
||||||
self::CUSTOMIZE_AUTHORIZATION_CODE => function (array $code) { return $code; }, // Default to no-op.
|
self::CUSTOMIZE_AUTHORIZATION_CODE => function (array $code) { return $code; }, // Default to no-op.
|
||||||
self::SHOW_AUTHORIZATION_PAGE => function (ServerRequestInterface $request, array $authenticationResult, string $authenticationRedirect) { }, // TODO: Put the default implementation here.
|
self::SHOW_AUTHORIZATION_PAGE => function (ServerRequestInterface $request, array $authenticationResult, string $authenticationRedirect, ?array $clientHApp) {
|
||||||
|
// TODO: Put the default implementation here.
|
||||||
|
},
|
||||||
self::HANDLE_NON_INDIEAUTH_REQUEST => function (ServerRequestInterface $request) { return null; }, // Default to no-op.
|
self::HANDLE_NON_INDIEAUTH_REQUEST => function (ServerRequestInterface $request) { return null; }, // Default to no-op.
|
||||||
],
|
],
|
||||||
'authorizationCodeStorage' => null,
|
'authorizationCodeStorage' => null,
|
||||||
|
@ -77,3 +77,17 @@ function trySetLogger($target, LoggerInterface $logger) {
|
|||||||
}
|
}
|
||||||
return $target;
|
return $target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderTemplate(string $template, array $context=[]) {
|
||||||
|
$render = function ($__template, $__templateData) {
|
||||||
|
$render = function ($template, $data){
|
||||||
|
return renderTemplate($template, $data);
|
||||||
|
};
|
||||||
|
ob_start();
|
||||||
|
extract($__templateData);
|
||||||
|
unset($__templateData);
|
||||||
|
include $__template;
|
||||||
|
return ob_get_clean();
|
||||||
|
};
|
||||||
|
return $render($template, $context);
|
||||||
|
}
|
||||||
|
24
src/templates/default_authorization_page.html.php
Normal file
24
src/templates/default_authorization_page.html.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/** @var string $authenticationRedirect The URL to POST to to authorize the app, or to set as the redirect URL for a logout action if the user wants to continue as a different user. */
|
||||||
|
/** @var Psr\Http\Message\ServerRequestInterface $request */
|
||||||
|
/** @var array|null $clientHApp */
|
||||||
|
/** @var array $me */
|
||||||
|
/** @var string $csrfFormElement A pre-rendered CSRF form element which must be output inside the authorization form. */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>IndieAuth • Authorize</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form method="post" action="<?= $authenticationRedirect ?>">
|
||||||
|
<?= $csrfFormElement ?>
|
||||||
|
|
||||||
|
<h1>Authorize</h1>
|
||||||
|
|
||||||
|
<!-- TODO -->
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -10,6 +10,7 @@ const TMP_DIR = __DIR__ . '/tmp';
|
|||||||
|
|
||||||
class FilesystemJsonStorageTest extends TestCase {
|
class FilesystemJsonStorageTest extends TestCase {
|
||||||
protected function setUp(): void {
|
protected function setUp(): void {
|
||||||
|
@mkdir(TMP_DIR);
|
||||||
// Clean tmp dir.
|
// Clean tmp dir.
|
||||||
foreach (new DirectoryIterator(TMP_DIR) as $fileInfo) {
|
foreach (new DirectoryIterator(TMP_DIR) as $fileInfo) {
|
||||||
if ($fileInfo->isFile()) {
|
if ($fileInfo->isFile()) {
|
||||||
@ -31,7 +32,7 @@ class FilesystemJsonStorageTest extends TestCase {
|
|||||||
$s = new FilesystemJsonStorage(TMP_DIR, 0, false);
|
$s = new FilesystemJsonStorage(TMP_DIR, 0, false);
|
||||||
|
|
||||||
$t1data = ['example' => 'data'];
|
$t1data = ['example' => 'data'];
|
||||||
$t1path = TMP_DIR . '/t1.json';
|
$t1path = $s->getPath('t1');
|
||||||
|
|
||||||
$this->assertTrue($s->put('t1', $t1data), "Saving t1 data failed");
|
$this->assertTrue($s->put('t1', $t1data), "Saving t1 data failed");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user