Added access key check with server
authorDaniel Davis <ddavis@w3.org>
Wed, 04 Sep 2013 16:41:11 +0900
changeset 51 6ca4bfdb5788
parent 50 a6ebae92b1e9 (current diff)
parent 49 fc1f736d9cbe (diff)
child 52 a17f441a38dc
Added access key check with server
--- a/autotweet-php/src/Org/W3/AutotweetBundle/Controller/DefaultController.php	Wed Sep 04 16:39:58 2013 +0900
+++ b/autotweet-php/src/Org/W3/AutotweetBundle/Controller/DefaultController.php	Wed Sep 04 16:41:11 2013 +0900
@@ -37,15 +37,20 @@
         return $this->render('OrgW3AutotweetBundle:Default:note.html.twig', array('post' => $post, 'talk' => $talk));
     }
     
-        public function checkKeyAction($key){
-        //$key=$this->get('request')->request->get('accesskey');
+        public function checkKeyAction(){
+        $key=$this->get('request')->request->get('accesskey');
+        if(null!=$key){
         $talk = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Talk')->findOneBy(array('accesskey'=>$key));
 	if(0!=count($talk)){
-            $valid='true';
+            $valid=true;
         }else{
-            $valid='false';
+            $valid=false;
+        }
+        }else{
+            $valid=false;
         }
         $response = new JsonResponse();
+        $response->headers->set('Access-Control-Allow-Origin','*');
         $response->setData(array(
             'accepted' => $valid
         ));
--- a/autotweet-php/src/Org/W3/AutotweetBundle/Resources/config/routing.yml	Wed Sep 04 16:39:58 2013 +0900
+++ b/autotweet-php/src/Org/W3/AutotweetBundle/Resources/config/routing.yml	Wed Sep 04 16:41:11 2013 +0900
@@ -14,7 +14,7 @@
     pattern:  /test
     defaults: { _controller: OrgW3AutotweetBundle:Default:test }
 org_w3_autotweet_checkkey:
-    pattern:  /checkkey/{key}
+    pattern:  /checkkey
     defaults: { _controller: OrgW3AutotweetBundle:Default:checkKey }
 login:
     pattern:   /login