Hide Patrons Circle polls behind login

This commit is contained in:
Alex Cabal 2022-07-09 10:57:11 -05:00
parent dbc2fd5fcd
commit edd032be2c
3 changed files with 32 additions and 23 deletions

View file

@ -283,7 +283,7 @@ Define webroot /standardebooks.org/web
# HTTP Basic Auth configuration for: # HTTP Basic Auth configuration for:
# /patrons-circle/downloads # /patrons-circle/downloads
# /feeds # /feeds
<DirectoryMatch "^${webroot}/www/(patrons-circle/downloads|feeds/(opds|rss|atom).*)"> <DirectoryMatch "^${webroot}/www/(patrons-circle|feeds/(opds|rss|atom))">
AuthType Basic AuthType Basic
AuthName "Enter your Patrons Circle email address and leave the password empty." AuthName "Enter your Patrons Circle email address and leave the password empty."
Require valid-user Require valid-user
@ -307,8 +307,8 @@ Define webroot /standardebooks.org/web
" "
</DirectoryMatch> </DirectoryMatch>
# Specific config for /patrons-circle # Specific config for /patrons-circle/downloads
<DirectoryMatch "^${webroot}/www/patrons-circle"> <DirectoryMatch "^${webroot}/www/patrons-circle/downloads">
<FilesMatch "\.php$"> <FilesMatch "\.php$">
# Disable HTTP Basic auth for the index and 401 pages # Disable HTTP Basic auth for the index and 401 pages
Require all granted Require all granted
@ -320,7 +320,7 @@ Define webroot /standardebooks.org/web
</DirectoryMatch> </DirectoryMatch>
# Specific config for /feeds # Specific config for /feeds
<DirectoryMatch "^${webroot}/www/feeds/(opds|rss|atom).*"> <DirectoryMatch "^${webroot}/www/feeds/(opds|rss|atom)">
ErrorDocument 401 /feeds/401 ErrorDocument 401 /feeds/401
<FilesMatch "^(style\.php|new-releases\.xml|index\.php|index\.xml)$"> <FilesMatch "^(style\.php|new-releases\.xml|index\.php|index\.xml)$">

View file

@ -265,7 +265,7 @@ Define webroot /standardebooks.org/web
# HTTP Basic Auth configuration for: # HTTP Basic Auth configuration for:
# /patrons-circle/downloads # /patrons-circle/downloads
# /feeds # /feeds
<DirectoryMatch "^${webroot}/www/(patrons-circle/downloads|feeds/(opds|rss|atom).*)"> <DirectoryMatch "^${webroot}/www/(patrons-circle|feeds/(opds|rss|atom))">
AuthType Basic AuthType Basic
AuthName "Enter your Patrons Circle email address and leave the password empty." AuthName "Enter your Patrons Circle email address and leave the password empty."
Require valid-user Require valid-user
@ -289,8 +289,8 @@ Define webroot /standardebooks.org/web
" "
</DirectoryMatch> </DirectoryMatch>
# Specific config for /patrons-circle # Specific config for /patrons-circle/downloads
<DirectoryMatch "^${webroot}/www/patrons-circle"> <DirectoryMatch "^${webroot}/www/patrons-circle/downloads">
<FilesMatch "\.php$"> <FilesMatch "\.php$">
# Disable HTTP Basic auth for the index and 401 pages # Disable HTTP Basic auth for the index and 401 pages
Require all granted Require all granted
@ -302,7 +302,7 @@ Define webroot /standardebooks.org/web
</DirectoryMatch> </DirectoryMatch>
# Specific config for /feeds # Specific config for /feeds
<DirectoryMatch "^${webroot}/www/feeds/(opds|rss|atom).*"> <DirectoryMatch "^${webroot}/www/feeds/(opds|rss|atom)">
ErrorDocument 401 /feeds/401 ErrorDocument 401 /feeds/401
<FilesMatch "^(style\.php|new-releases\.xml|index\.php|index\.xml)$"> <FilesMatch "^(style\.php|new-releases\.xml|index\.php|index\.xml)$">

View file

@ -5,7 +5,16 @@ use function Safe\session_unset;
session_start(); session_start();
$vote = $_SESSION['vote'] ?? new PollVote(); $vote = new PollVote();
if(isset($_SESSION['vote'])){
$vote = $_SESSION['vote'];
}
else{
$vote->User = new User();
$vote->User->Email = $_SERVER['PHP_AUTH_USER'] ?? null;
}
$exception = $_SESSION['exception'] ?? null; $exception = $_SESSION['exception'] ?? null;
$poll = new Poll(); $poll = new Poll();
@ -29,7 +38,7 @@ if($exception){
<?= Template::Error(['exception' => $exception]) ?> <?= Template::Error(['exception' => $exception]) ?>
<form method="post" action="<?= Formatter::ToPlainText($poll->Url) ?>/votes"> <form method="post" action="<?= Formatter::ToPlainText($poll->Url) ?>/votes">
<label class="email">Your email address <label class="email">Your email address
<input type="email" name="email" value="<? if($vote->User !== null){ ?><?= Formatter::ToPlainText($vote->User->Email) ?><? } ?>" maxlength="80" required="required" /> <input type="email" name="email" value="<? if($vote->User !== null){ ?><?= Formatter::ToPlainText($vote->User->Email) ?><? } ?>" maxlength="80" required="required" readonly="readonly" />
</label> </label>
<fieldset> <fieldset>
<p>Select one of these options</p> <p>Select one of these options</p>