From cce2319a10abc09ae7d7d8b2c421915032927f99 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Thu, 11 Jun 2020 15:55:05 +0200 Subject: [PATCH] fix #18 env infos --- .env | 12 ++++++------ README.md | 5 ++++- src/Controller/VoteController.php | 23 +++++------------------ 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/.env b/.env index a56f4ff..ba017c1 100755 --- a/.env +++ b/.env @@ -15,10 +15,10 @@ ###> symfony/framework-bundle ### APP_ENV=dev -ADMIN_TOKEN=erfd456ref4ety4h56jy4i5opuoipm564iyuyn312b1s6er78g897ryjt7thsb32d1gfb -APP_SECRET=597b0529ac702d27dcb9089f7e69c362 +ADMIN_TOKEN=CHANGE_THIS_STRING_HERE +APP_SECRET=CHANGE_THIS_STRING_THERE # Base website url, should contain https:// and having no trailing slash. example: BASE_URL=https://framadate.org -BASE_URL=https://framadate-api.cipherbliss.com +BASE_URL=https://YOUR_WEBSITE #TRUSTED_PROXIES=127.0.0.1,127.0.0.2 #TRUSTED_HOSTS='^localhost|example\.com$' ###< symfony/framework-bundle ### @@ -28,7 +28,7 @@ BASE_URL=https://framadate-api.cipherbliss.com # For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db" # For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11" # IMPORTANT: You MUST also configure your db driver and server_version in config/packages/doctrine.yaml -DATABASE_URL=mysql://root:tiptaoptidou132548@127.0.0.1:5432/symfony +DATABASE_URL=mysql://MYSQL_USER:MYSQL_PASS@127.0.0.1:5432/symfony ###< doctrine/doctrine-bundle ### ###> nelmio/cors-bundle ### @@ -39,9 +39,9 @@ CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$ # For Gmail as a transport, use: "gmail://username:password@localhost" # For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" # Delivery is disabled by default via "null://localhost" -MAILER_URL=sendmail://framadate-api.cipherbliss.com +MAILER_URL=sendmail://YOUR_WEBSITE # set the support email who will answer users in case of emergency -SUPPORT_EMAIL=admin_framadate@yopmail.com +SUPPORT_EMAIL=YOUR_EMAIL ###< symfony/swiftmailer-bundle ### ###> symfony/mailer ### diff --git a/README.md b/README.md index 9c8a8da..76f7c19 100755 --- a/README.md +++ b/README.md @@ -3,9 +3,12 @@ Experimental REST backend in symfony 4 for Funky framadate frontend. https://framagit.org/framasoft/framadate/funky-framadate-front Follow this guide to setup. - +* run `composer install` +configure env by creating local env file +`cp .env .env.local` and edit the file variables to give access to database. ## TODO: +* coordinate properties and paths to be more restful. return stack of votes when we want to get the configuration of one poll (see [doc/examples.md](doc/examples.md)) diff --git a/src/Controller/VoteController.php b/src/Controller/VoteController.php index 1b4687e..9d83fb3 100644 --- a/src/Controller/VoteController.php +++ b/src/Controller/VoteController.php @@ -26,7 +26,7 @@ class VoteController extends FramadateController { /** * add a vote stack on a poll * @Post( - * path = "/poll/{id}/vote", + * path = "/poll/{id}/answer", * name = "new_vote_stack", * requirements = {"content"="\w+", "poll_id"="\d+"} * ) @@ -119,20 +119,7 @@ class VoteController extends FramadateController { $this->sendVoteNotificationAction($stack->getOwner(), $stack); } - $returnedVoteStack = [ - 'message' => 'you created a vote stack' . $precision, - 'poll' => $poll, - 'vote_stack' => $stack, - 'stacks' => $stacks, - 'comments' => $poll->getComments(), - 'choices' => $poll->getChoices(), - 'choices_count' => $poll->computeAnswers(), - 'vote_count' => count( $stacks ), - 'owner' => $stack->getOwner(), - 'owner_modifier_token' => $stack->getOwner()->getModifierToken(), - 'admin_key' => $poll->getAdminKey(), - 'json_you_sent' => $data, - ]; + $returnedVoteStack = $stack; $jsonResponse = $serializer->serialize($returnedVoteStack, 'json'); @@ -219,11 +206,11 @@ class VoteController extends FramadateController { return $this->json( [ 'message' => 'boom! les ' . $length . ' votes du sondage ont été supprimés', - ] ); + ],200 ); } else { return $this->json( [ - 'message' => 'le token d\'autorisation est invalide, vous ne pouvez pas modifier ce sondage', - ] ); + 'message' => 'le token d\'autorisation est invalide, vous ne pouvez pas modifier ce sondage' + ],403 ); } } }