Add admin form to view and edit users

This commit is contained in:
Alex Cabal 2024-11-23 13:13:31 -06:00
parent 32607fb220
commit 8ad3291a35
35 changed files with 902 additions and 72 deletions

View file

@ -4,20 +4,14 @@ use function Safe\session_unset;
session_start();
$poll = new Poll();
$vote = new PollVote();
/** @var ?\Exception $exception */
$exception = $_SESSION['exception'] ?? null;
$vote = HttpInput::SessionObject('vote', PollVote::class) ?? new PollVote();
$exception = HttpInput::SessionObject('exception', Exceptions\AppException::class);
try{
if(Session::$User === null){
throw new Exceptions\LoginRequiredException();
}
if(isset($_SESSION['vote'])){
/** @var PollVote $vote */
$vote = $_SESSION['vote'];
}
if(!isset($vote->UserId)){
$vote->UserId = Session::$User->UserId;
$vote->User = Session::$User;
@ -60,7 +54,7 @@ catch(Exceptions\PollVoteExistsException $ex){
<section class="narrow">
<h1>Vote in the <?= Formatter::EscapeHtml($poll->Name) ?> Poll</h1>
<?= Template::Error(['exception' => $exception]) ?>
<form method="post" action="<?= Formatter::EscapeHtml($poll->Url) ?>/votes">
<form method="<?= Enums\HttpMethod::Post->value ?>" action="<?= Formatter::EscapeHtml($poll->Url) ?>/votes">
<input type="hidden" name="email" value="<?= Formatter::EscapeHtml($vote->User->Email) ?>" maxlength="80" required="required" />
<fieldset>
<p>Select one of these options.</p>