1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00

add get admin config for poll

This commit is contained in:
Tykayn 2021-05-03 14:03:21 +02:00 committed by tykayn
parent cc74a08603
commit 93a567184a

View File

@ -148,7 +148,7 @@ class PollController extends EmailsController {
// wrong pass
return $this->json( [
'message' => 'this is protected by a password, your password hash "' . $md5 . '" is wrong, and you should feel bad',
'md5' => md5( $md5 ),
// 'md5' => md5( $md5 ),
'data' => null,
],
403 );
@ -157,6 +157,35 @@ class PollController extends EmailsController {
}
/**
* as an administrator of a poll, get a poll config by its custom URL, we do not want polls to be reachable by their numeric id
* @Get(
* path = "admin/{admin_key}",
* name = "get_admin_poll",
* )
*
* @param SerializerInterface $serializer
* @param Request $request
*
* @return JsonResponse|Response
*/
function getAdminPoll( $admin_key, $md5, SerializerInterface $serializer ) {
$repository = $this->getDoctrine()->getRepository( Poll::class );
$poll = $repository->findOneByAdminKey( $admin_key );
if ( ! $poll ) {
return $this->notFoundPoll( $admin_key );
}
// good matching pass
return $this->json( $poll->displayForAdmin() );
}
function returnPollData( $poll, $serializer ) {
$jsonResponse = $serializer->serialize( $poll, 'json' );