Browse Source

Evolution #161: Session sécurité

Sevajol Bastien 12 years ago
parent
commit
d0ae725828
26 changed files with 104 additions and 98 deletions
  1. 6 6
      src/Muzich/CommentBundle/Controller/CommentController.php
  2. 3 3
      src/Muzich/CommentBundle/Resources/views/Comment/comment.html.twig
  3. 1 1
      src/Muzich/CommentBundle/Resources/views/Comment/edit.html.twig
  4. 4 4
      src/Muzich/CoreBundle/Controller/CoreController.php
  5. 12 7
      src/Muzich/CoreBundle/Controller/ElementController.php
  6. 1 1
      src/Muzich/CoreBundle/Resources/config/routing.yml
  7. 3 3
      src/Muzich/CoreBundle/Resources/views/Element/tag.propositions.html.twig
  8. 8 8
      src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig
  9. 5 5
      src/Muzich/CoreBundle/Tests/Controller/CommentControllerTest.php
  10. 10 10
      src/Muzich/CoreBundle/Tests/Controller/ElementControllerTest.php
  11. 14 14
      src/Muzich/CoreBundle/Tests/Controller/EventTest.php
  12. 4 4
      src/Muzich/CoreBundle/Tests/Controller/FavoriteControllerTest.php
  13. 1 1
      src/Muzich/CoreBundle/Tests/Controller/GroupControllerTest.php
  14. 3 3
      src/Muzich/CoreBundle/Tests/Controller/HomeControllerTest.php
  15. 7 7
      src/Muzich/CoreBundle/Tests/Controller/ModerateControllerTest.php
  16. 2 2
      src/Muzich/CoreBundle/Tests/Controller/MynetworkControllerTest.php
  17. 3 2
      src/Muzich/CoreBundle/Tests/Controller/ReputationTest.php
  18. 4 4
      src/Muzich/CoreBundle/Tests/Controller/ShowControllerTest.php
  19. 1 1
      src/Muzich/CoreBundle/Tests/Controller/TagsTest.php
  20. 3 3
      src/Muzich/CoreBundle/Tests/Controller/UserControllerTest.php
  21. 1 1
      src/Muzich/CoreBundle/lib/Controller.php
  22. 4 4
      src/Muzich/FavoriteBundle/Controller/FavoriteController.php
  23. 1 1
      src/Muzich/GroupBundle/Controller/DefaultController.php
  24. 1 1
      src/Muzich/GroupBundle/Resources/views/Default/myList.html.twig
  25. 1 1
      src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig
  26. 1 1
      src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig

+ 6 - 6
src/Muzich/CommentBundle/Controller/CommentController.php View File

24
     }
24
     }
25
     
25
     
26
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
26
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
27
-      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
27
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash($element_id) != $token)
28
     {
28
     {
29
       return $this->jsonResponse(array(
29
       return $this->jsonResponse(array(
30
         'status' => 'error',
30
         'status' => 'error',
109
     }
109
     }
110
     
110
     
111
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
111
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
112
-      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
112
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash($element_id) != $token)
113
     {
113
     {
114
       return $this->jsonResponse(array(
114
       return $this->jsonResponse(array(
115
         'status' => 'error',
115
         'status' => 'error',
161
     }
161
     }
162
     
162
     
163
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
163
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
164
-      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
164
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash($element_id) != $token)
165
     {
165
     {
166
       return $this->jsonResponse(array(
166
       return $this->jsonResponse(array(
167
         'status' => 'error',
167
         'status' => 'error',
206
     }
206
     }
207
     
207
     
208
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
208
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
209
-      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
209
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash($element_id) != $token)
210
     {
210
     {
211
       return $this->jsonResponse(array(
211
       return $this->jsonResponse(array(
212
         'status' => 'error',
212
         'status' => 'error',
305
     }
305
     }
306
     
306
     
307
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
307
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
308
-      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
308
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash($element_id) != $token)
309
     {
309
     {
310
       return $this->jsonResponse(array(
310
       return $this->jsonResponse(array(
311
         'status' => 'error',
311
         'status' => 'error',
344
     }
344
     }
345
     
345
     
346
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
346
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
347
-      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
347
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash($element_id) != $token)
348
     {
348
     {
349
       return $this->jsonResponse(array(
349
       return $this->jsonResponse(array(
350
         'status' => 'error',
350
         'status' => 'error',

+ 3 - 3
src/Muzich/CommentBundle/Resources/views/Comment/comment.html.twig View File

8
 {% if app.user.id != comment.u.i %}
8
 {% if app.user.id != comment.u.i %}
9
   <a title="{{ 'comment.report.link_title'|trans({}, 'userui') }}" 
9
   <a title="{{ 'comment.report.link_title'|trans({}, 'userui') }}" 
10
     class="comment_report" 
10
     class="comment_report" 
11
-    href="{{ path('ajax_alert_comment', {'element_id':element_id, 'date': comment.d, 'token':app.user.getPersonalHash}) }}">
11
+    href="{{ path('ajax_alert_comment', {'element_id':element_id, 'date': comment.d, 'token':app.user.getPersonalHash(element_id)}) }}">
12
     <img src="{{ asset('bundles/muzichcore/img/1331832708_comment_alert.png') }}" alt="report" />
12
     <img src="{{ asset('bundles/muzichcore/img/1331832708_comment_alert.png') }}" alt="report" />
13
   </a>
13
   </a>
14
 {% endif %}
14
 {% endif %}
15
 
15
 
16
 {% if app.user.id == comment.u.i %}
16
 {% if app.user.id == comment.u.i %}
17
   <a title="{{ 'comment.edit.link'|trans({}, 'elements') }}" class="comment_edit_link" 
17
   <a title="{{ 'comment.edit.link'|trans({}, 'elements') }}" class="comment_edit_link" 
18
-     href="{{ path('ajax_edit_comment', {'element_id': element_id, 'date':comment.d, 'token':app.user.getPersonalHash})  }}" style="display: none;"
18
+     href="{{ path('ajax_edit_comment', {'element_id': element_id, 'date':comment.d, 'token':app.user.getPersonalHash(element_id)})  }}" style="display: none;"
19
   >
19
   >
20
     <img src="{{ asset('bundles/muzichcore/img/1327151338_desktop.png') }}" alt="edit" />
20
     <img src="{{ asset('bundles/muzichcore/img/1327151338_desktop.png') }}" alt="edit" />
21
   </a>
21
   </a>
22
 
22
 
23
   <a title="{{ 'comment.remove.link'|trans({}, 'elements') }}" class="comment_remove_link" 
23
   <a title="{{ 'comment.remove.link'|trans({}, 'elements') }}" class="comment_remove_link" 
24
-     href="{{ path('ajax_delete_comment', {'element_id': element_id, 'date':comment.d, 'token':app.user.getPersonalHash})  }}" style="display: none;"
24
+     href="{{ path('ajax_delete_comment', {'element_id': element_id, 'date':comment.d, 'token':app.user.getPersonalHash(element_id)})  }}" style="display: none;"
25
   >
25
   >
26
     <img src="{{ asset('bundles/muzichcore/img/1327168960_fileclose.png') }}" alt="delete" />
26
     <img src="{{ asset('bundles/muzichcore/img/1327168960_fileclose.png') }}" alt="delete" />
27
   </a>
27
   </a>

+ 1 - 1
src/Muzich/CommentBundle/Resources/views/Comment/edit.html.twig View File

3
   action="{{ path('ajax_update_comment', {
3
   action="{{ path('ajax_update_comment', {
4
     'element_id':element_id, 
4
     'element_id':element_id, 
5
     'date': date, 
5
     'date': date, 
6
-    'token':app.user.getPersonalHash,
6
+    'token':app.user.getPersonalHash(element_id),
7
     'dom_id': comment.u.i~'_'~(comment.d|date_epurate)
7
     'dom_id': comment.u.i~'_'~(comment.d|date_epurate)
8
   }) }}" 
8
   }) }}" 
9
   method="post" 
9
   method="post" 

+ 4 - 4
src/Muzich/CoreBundle/Controller/CoreController.php View File

128
     }
128
     }
129
     
129
     
130
     // Vérifications préléminaires
130
     // Vérifications préléminaires
131
-    if ($user->getPersonalHash() != $token 
131
+    if ($user->getPersonalHash($id) != $token 
132
         || !in_array($type, array('user', 'group')) 
132
         || !in_array($type, array('user', 'group')) 
133
         || !is_numeric($id)
133
         || !is_numeric($id)
134
         || ($user->getId() == $id && $type == 'user')
134
         || ($user->getId() == $id && $type == 'user')
523
     }
523
     }
524
     
524
     
525
     if (!($tag = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
525
     if (!($tag = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
526
-      ->findOneById($tag_id)) || $this->getUser()->getPersonalHash() != $token)
526
+      ->findOneById($tag_id)) || $this->getUser()->getPersonalHash($tag_id) != $token)
527
     {
527
     {
528
       return $this->jsonResponse(array(
528
       return $this->jsonResponse(array(
529
         'status' => 'error',
529
         'status' => 'error',
586
       ->findOneById($element_id)) 
586
       ->findOneById($element_id)) 
587
       || !($group = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
587
       || !($group = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
588
       ->findOneById($group_id)) 
588
       ->findOneById($group_id)) 
589
-      || $this->getUser()->getPersonalHash() != $token)
589
+      || $this->getUser()->getPersonalHash($element_id) != $token)
590
     {
590
     {
591
       return $this->jsonResponse(array(
591
       return $this->jsonResponse(array(
592
         'status' => 'error',
592
         'status' => 'error',
637
     
637
     
638
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
638
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
639
       ->findOneById($element_id)) 
639
       ->findOneById($element_id)) 
640
-      || $this->getUser()->getPersonalHash() != $token)
640
+      || $this->getUser()->getPersonalHash($element_id) != $token)
641
     {
641
     {
642
       return $this->jsonResponse(array(
642
       return $this->jsonResponse(array(
643
         'status' => 'error',
643
         'status' => 'error',

+ 12 - 7
src/Muzich/CoreBundle/Controller/ElementController.php View File

202
    * @param int $element_id
202
    * @param int $element_id
203
    * @return Response 
203
    * @return Response 
204
    */
204
    */
205
-  public function removeAction($element_id)
205
+  public function removeAction($element_id, $token)
206
   {
206
   {
207
     if (($response = $this->mustBeConnected()))
207
     if (($response = $this->mustBeConnected()))
208
     {
208
     {
209
       return $response;
209
       return $response;
210
     }
210
     }
211
     
211
     
212
+    if ($token != $this->getUser()->getPersonalHash($element_id))
213
+    {
214
+      return $this->jsonResponse(array('status' => 'error'));
215
+    }
216
+    
212
     try {
217
     try {
213
       $element = $this->checkExistingAndOwned($element_id);
218
       $element = $this->checkExistingAndOwned($element_id);
214
       $em = $this->getDoctrine()->getEntityManager();
219
       $em = $this->getDoctrine()->getEntityManager();
455
     }
460
     }
456
     
461
     
457
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
462
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
458
-      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
463
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash($element_id) != $token)
459
     {
464
     {
460
       return $this->jsonResponse(array(
465
       return $this->jsonResponse(array(
461
         'status' => 'error',
466
         'status' => 'error',
486
         'a' => array(
491
         'a' => array(
487
           'href' => $this->generateUrl('ajax_element_remove_vote_good', array(
492
           'href' => $this->generateUrl('ajax_element_remove_vote_good', array(
488
             'element_id' => $element->getId(),
493
             'element_id' => $element->getId(),
489
-            'token'      => $this->getUser()->getPersonalHash()
494
+            'token'      => $this->getUser()->getPersonalHash($element->getId())
490
           ))
495
           ))
491
         ),
496
         ),
492
         'img' => array(
497
         'img' => array(
514
     }
519
     }
515
     
520
     
516
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
521
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
517
-      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
522
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash($element_id) != $token)
518
     {
523
     {
519
       return $this->jsonResponse(array(
524
       return $this->jsonResponse(array(
520
         'status' => 'error',
525
         'status' => 'error',
545
         'a' => array(
550
         'a' => array(
546
           'href' => $this->generateUrl('ajax_element_add_vote_good', array(
551
           'href' => $this->generateUrl('ajax_element_add_vote_good', array(
547
             'element_id' => $element->getId(),
552
             'element_id' => $element->getId(),
548
-            'token'      => $this->getUser()->getPersonalHash()
553
+            'token'      => $this->getUser()->getPersonalHash($element->getId())
549
           ))
554
           ))
550
         ),
555
         ),
551
         'img' => array(
556
         'img' => array(
754
     }
759
     }
755
     
760
     
756
     if (!($proposition = $this->getDoctrine()->getRepository('MuzichCoreBundle:ElementTagsProposition')
761
     if (!($proposition = $this->getDoctrine()->getRepository('MuzichCoreBundle:ElementTagsProposition')
757
-      ->findOneById($proposition_id)) || $token != $this->getUser()->getPersonalHash())
762
+      ->findOneById($proposition_id)) || $token != $this->getUser()->getPersonalHash($proposition_id))
758
     {
763
     {
759
       return $this->jsonResponse(array(
764
       return $this->jsonResponse(array(
760
         'status' => 'error',
765
         'status' => 'error',
813
     }
818
     }
814
     
819
     
815
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
820
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
816
-      ->findOneById($element_id)) || $token != $this->getUser()->getPersonalHash())
821
+      ->findOneById($element_id)) || $token != $this->getUser()->getPersonalHash($element_id))
817
     {
822
     {
818
       return $this->jsonResponse(array(
823
       return $this->jsonResponse(array(
819
         'status' => 'error',
824
         'status' => 'error',

+ 1 - 1
src/Muzich/CoreBundle/Resources/config/routing.yml View File

93
   defaults: { _controller: MuzichCoreBundle:Element:update }
93
   defaults: { _controller: MuzichCoreBundle:Element:update }
94
   
94
   
95
 element_remove:
95
 element_remove:
96
-  pattern: /element/{element_id}/remove
96
+  pattern: /element/{element_id}/remove/{token}
97
   defaults: { _controller: MuzichCoreBundle:Element:remove }
97
   defaults: { _controller: MuzichCoreBundle:Element:remove }
98
   
98
   
99
 element_new_count:
99
 element_new_count:

+ 3 - 3
src/Muzich/CoreBundle/Resources/views/Element/tag.propositions.html.twig View File

19
           <span class="button">{{ tag.name }}</span>
19
           <span class="button">{{ tag.name }}</span>
20
         {% endfor %}
20
         {% endfor %}
21
           
21
           
22
-          <a class="accept_tag_propotision button darkbutton" href="{{ path('ajax_element_proposed_tags_accept', {'proposition_id':proposition.id,'token':app.user.getPersonalHash}) }}">
22
+          <a class="accept_tag_propotision button darkbutton" href="{{ path('ajax_element_proposed_tags_accept', {'proposition_id':proposition.id,'token':app.user.getPersonalHash(proposition.id)}) }}">
23
             {{ 'element.view_propositions.link_accept'|trans({}, 'elements') }}
23
             {{ 'element.view_propositions.link_accept'|trans({}, 'elements') }}
24
           </a>
24
           </a>
25
           
25
           
28
   </ul>
28
   </ul>
29
   
29
   
30
   {% if propositions|length > 1 %}
30
   {% if propositions|length > 1 %}
31
-    <a class="refuse_tag_propositions button darkbutton" href="{{ path('ajax_element_proposed_tags_refuse', {'element_id':element_id,'token':app.user.getPersonalHash}) }}" >
31
+    <a class="refuse_tag_propositions button darkbutton" href="{{ path('ajax_element_proposed_tags_refuse', {'element_id':element_id,'token':app.user.getPersonalHash(element_id)}) }}" >
32
       {{ 'element.view_propositions.link_refuse_x'|trans({}, 'elements') }}
32
       {{ 'element.view_propositions.link_refuse_x'|trans({}, 'elements') }}
33
     </a>
33
     </a>
34
   {% else %}
34
   {% else %}
35
-    <a class="refuse_tag_propositions button darkbutton" href="{{ path('ajax_element_proposed_tags_refuse', {'element_id':element_id,'token':app.user.getPersonalHash}) }}" >
35
+    <a class="refuse_tag_propositions button darkbutton" href="{{ path('ajax_element_proposed_tags_refuse', {'element_id':element_id,'token':app.user.getPersonalHash(element_id)}) }}" >
36
       {{ 'element.view_propositions.link_refuse_one'|trans({}, 'elements') }}
36
       {{ 'element.view_propositions.link_refuse_one'|trans({}, 'elements') }}
37
     </a>
37
     </a>
38
   {% endif %}
38
   {% endif %}

+ 8 - 8
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig View File

54
               {% if element.hasVoteGood(app.user.id) %}
54
               {% if element.hasVoteGood(app.user.id) %}
55
                 <a class="vote" href="{{ path('ajax_element_remove_vote_good', {
55
                 <a class="vote" href="{{ path('ajax_element_remove_vote_good', {
56
                   'element_id' : element.id,
56
                   'element_id' : element.id,
57
-                  'token'      : app.user.getPersonalHash
57
+                  'token'      : app.user.getPersonalHash(element.id)
58
                 }) }}" title="{{ 'element.vote.good'|trans({}, 'elements') }}">
58
                 }) }}" title="{{ 'element.vote.good'|trans({}, 'elements') }}">
59
                   <img src="{{ asset('img/icon_thumb_red.png') }}" alt="vote" />
59
                   <img src="{{ asset('img/icon_thumb_red.png') }}" alt="vote" />
60
                 </a>
60
                 </a>
61
               {% else %}
61
               {% else %}
62
                 <a class="vote" href="{{ path('ajax_element_add_vote_good', {
62
                 <a class="vote" href="{{ path('ajax_element_add_vote_good', {
63
                   'element_id' : element.id,
63
                   'element_id' : element.id,
64
-                  'token'      : app.user.getPersonalHash
64
+                  'token'      : app.user.getPersonalHash(element.id)
65
                 }) }}" title="{{ 'element.vote.good'|trans({}, 'elements') }}">
65
                 }) }}" title="{{ 'element.vote.good'|trans({}, 'elements') }}">
66
                   <img src="{{ asset('img/icon_thumb.png') }}" alt="vote" />
66
                   <img src="{{ asset('img/icon_thumb.png') }}" alt="vote" />
67
                 </a>
67
                 </a>
70
         {% endif %}
70
         {% endif %}
71
         <li class="star">
71
         <li class="star">
72
           {% if element.hasFavoriteUser(app.user.id) %}
72
           {% if element.hasFavoriteUser(app.user.id) %}
73
-            <a class="favorite_link" href="{{ path('favorite_remove', { 'id': element.id, 'token': app.user.personalHash }) }}" >
73
+            <a class="favorite_link" href="{{ path('favorite_remove', { 'id': element.id, 'token': app.user.personalHash(element.id) }) }}" >
74
               <img id="favorite_{{ element.id }}_is" src="{{ asset('img/icon_star_2_red.png') }}" title="{{ 'element.favorite.remove'|trans({}, 'elements') }}" alt="{{ 'element.favorite.remove'|trans({}, 'elements') }}"/>
74
               <img id="favorite_{{ element.id }}_is" src="{{ asset('img/icon_star_2_red.png') }}" title="{{ 'element.favorite.remove'|trans({}, 'elements') }}" alt="{{ 'element.favorite.remove'|trans({}, 'elements') }}"/>
75
             </a>
75
             </a>
76
           {% else %}
76
           {% else %}
77
-            <a class="favorite_link" href="{{ path('favorite_add', { 'id': element.id, 'token': app.user.personalHash }) }}" >
77
+            <a class="favorite_link" href="{{ path('favorite_add', { 'id': element.id, 'token': app.user.personalHash(element.id) }) }}" >
78
               <img id="favorite_{{ element.id }}_isnot" src="{{ asset('img/icon_star_2.png') }}" title="{{ 'element.favorite.add'|trans({}, 'elements') }}" alt="{{ 'element.favorite.add'|trans({}, 'elements') }}" />
78
               <img id="favorite_{{ element.id }}_isnot" src="{{ asset('img/icon_star_2.png') }}" title="{{ 'element.favorite.add'|trans({}, 'elements') }}" alt="{{ 'element.favorite.add'|trans({}, 'elements') }}" />
79
             </a>
79
             </a>
80
           {% endif %}
80
           {% endif %}
113
             <li class="element_report">
113
             <li class="element_report">
114
               <a title="{{ 'element.report.link_title'|trans({}, 'userui') }}" 
114
               <a title="{{ 'element.report.link_title'|trans({}, 'userui') }}" 
115
                 class="element_report" 
115
                 class="element_report" 
116
-                href="{{ path('ajax_report_element', {'element_id':element.id, 'token':app.user.getPersonalHash}) }}">
116
+                href="{{ path('ajax_report_element', {'element_id':element.id, 'token':app.user.getPersonalHash(element.id)}) }}">
117
                 <img src="{{ asset('/img/icon_alert.png') }}" alt="report" />
117
                 <img src="{{ asset('/img/icon_alert.png') }}" alt="report" />
118
               </a>
118
               </a>
119
             </li>
119
             </li>
146
 
146
 
147
             <li class="element_remove_link">
147
             <li class="element_remove_link">
148
               <a title="{{ 'element.remove.link'|trans({}, 'elements') }}" class="element_remove_link" 
148
               <a title="{{ 'element.remove.link'|trans({}, 'elements') }}" class="element_remove_link" 
149
-                href="{{ path('element_remove', {'element_id' : element.id})  }}"
149
+                href="{{ path('element_remove', {'element_id' : element.id, 'token':app.user.getPersonalHash(element.id)})  }}"
150
               >
150
               >
151
                 <img src="{{ asset('/img/icon_close_2.png') }}" alt="delete" />
151
                 <img src="{{ asset('/img/icon_close_2.png') }}" alt="delete" />
152
               </a>
152
               </a>
230
               <a 
230
               <a 
231
                 href="{{ path('ajax_tag_add_to_favorites', {
231
                 href="{{ path('ajax_tag_add_to_favorites', {
232
                   'tag_id' : tag.id,
232
                   'tag_id' : tag.id,
233
-                  'token'  : app.user.getPersonalHash
233
+                  'token'  : app.user.getPersonalHash(tag.id)
234
                 }) }}" 
234
                 }) }}" 
235
                 class="tag_to_favorites" 
235
                 class="tag_to_favorites" 
236
                 style="display: none;"
236
                 style="display: none;"
310
     </div>
310
     </div>
311
       
311
       
312
     <form 
312
     <form 
313
-      action="{{ path('ajax_add_comment', {'element_id':element.id, 'token':app.user.getPersonalHash}) }}" 
313
+      action="{{ path('ajax_add_comment', {'element_id':element.id, 'token':app.user.getPersonalHash(element.id)}) }}" 
314
       method="post" 
314
       method="post" 
315
       name="add_comment"
315
       name="add_comment"
316
       style="display: none;"
316
       style="display: none;"

+ 5 - 5
src/Muzich/CoreBundle/Tests/Controller/CommentControllerTest.php View File

45
       'POST', 
45
       'POST', 
46
       $this->generateUrl('ajax_add_comment', array(
46
       $this->generateUrl('ajax_add_comment', array(
47
         'element_id' => $element->getId(),
47
         'element_id' => $element->getId(),
48
-        'token'      => $this->getUser()->getPersonalHash()
48
+        'token'      => $this->getUser()->getPersonalHash($element->getId())
49
       )), 
49
       )), 
50
       array(
50
       array(
51
           'comment' => "J'ai réécouté et ouaa je kiff BrOOO"
51
           'comment' => "J'ai réécouté et ouaa je kiff BrOOO"
84
         'element_id' => $element->getId(),
84
         'element_id' => $element->getId(),
85
         'date'       => $comment['d'],
85
         'date'       => $comment['d'],
86
         'dom_id'     => $id,
86
         'dom_id'     => $id,
87
-        'token'      => $this->getUser()->getPersonalHash()
87
+        'token'      => $this->getUser()->getPersonalHash($element->getId())
88
       )),
88
       )),
89
       array(
89
       array(
90
           'comment' => "Je me modifie mon com kwaa"
90
           'comment' => "Je me modifie mon com kwaa"
118
       $this->generateUrl('ajax_delete_comment', array(
118
       $this->generateUrl('ajax_delete_comment', array(
119
         'element_id' => $element->getId(),
119
         'element_id' => $element->getId(),
120
         'date'       => $comment['d'],
120
         'date'       => $comment['d'],
121
-        'token'      => $this->getUser()->getPersonalHash()
121
+        'token'      => $this->getUser()->getPersonalHash($element->getId())
122
       )),
122
       )),
123
       array(), 
123
       array(), 
124
       array(), 
124
       array(), 
174
         'element_id' => $element->getId(),
174
         'element_id' => $element->getId(),
175
         'date'       => $comment['d'],
175
         'date'       => $comment['d'],
176
         'dom_id'     => $id,
176
         'dom_id'     => $id,
177
-        'token'      => $this->getUser()->getPersonalHash()
177
+        'token'      => $this->getUser()->getPersonalHash($element->getId())
178
       )),
178
       )),
179
       array(
179
       array(
180
           'comment' => "Je répond 13 HACKED"
180
           'comment' => "Je répond 13 HACKED"
194
       $this->generateUrl('ajax_delete_comment', array(
194
       $this->generateUrl('ajax_delete_comment', array(
195
         'element_id' => $element->getId(),
195
         'element_id' => $element->getId(),
196
         'date'       => $comment['d'],
196
         'date'       => $comment['d'],
197
-        'token'      => $this->getUser()->getPersonalHash()
197
+        'token'      => $this->getUser()->getPersonalHash($element->getId())
198
       )),
198
       )),
199
       array(), 
199
       array(), 
200
       array(), 
200
       array(), 

+ 10 - 10
src/Muzich/CoreBundle/Tests/Controller/ElementControllerTest.php View File

298
     
298
     
299
     // On est sur la page home, on peut voir le lien de suppression l'élément
299
     // On est sur la page home, on peut voir le lien de suppression l'élément
300
     $this->exist('a[href="'.($url = $this->generateUrl('element_remove', array(
300
     $this->exist('a[href="'.($url = $this->generateUrl('element_remove', array(
301
-        'element_id' => $element->getId()
301
+        'element_id' => $element->getId(), 'token' => $bux->getPersonalHash($element->getId())
302
     ))).'"]');
302
     ))).'"]');
303
   
303
   
304
     // Suppression de l'élément
304
     // Suppression de l'élément
346
     // On peut donc voir le lien pour "dé-voter"
346
     // On peut donc voir le lien pour "dé-voter"
347
     $url_unvote_soul = $this->generateUrl('ajax_element_remove_vote_good', array(
347
     $url_unvote_soul = $this->generateUrl('ajax_element_remove_vote_good', array(
348
       'element_id' => $element_soul->getId(),
348
       'element_id' => $element_soul->getId(),
349
-      'token' => $paul->getPersonalHash()
349
+      'token' => $paul->getPersonalHash($element_soul->getId())
350
     ));
350
     ));
351
     $this->exist('a.vote[href="'.$url_unvote_soul.'"]');
351
     $this->exist('a.vote[href="'.$url_unvote_soul.'"]');
352
     
352
     
378
       'GET', 
378
       'GET', 
379
       $this->generateUrl('ajax_element_add_vote_good', array(
379
       $this->generateUrl('ajax_element_add_vote_good', array(
380
         'element_id' => $element_ed->getId(),
380
         'element_id' => $element_ed->getId(),
381
-        'token' => $paul->getPersonalHash()
381
+        'token' => $paul->getPersonalHash($element_ed->getId())
382
       )), 
382
       )), 
383
       array(), 
383
       array(), 
384
       array(), 
384
       array(), 
441
       'GET', 
441
       'GET', 
442
       $this->generateUrl('ajax_element_add_vote_good', array(
442
       $this->generateUrl('ajax_element_add_vote_good', array(
443
         'element_id' => $element_ed->getId(),
443
         'element_id' => $element_ed->getId(),
444
-        'token' => $bob->getPersonalHash()
444
+        'token' => $bob->getPersonalHash($element_ed->getId())
445
       )), 
445
       )), 
446
       array(), 
446
       array(), 
447
       array(), 
447
       array(), 
729
     
729
     
730
     $url_accept_paul = $this->generateUrl('ajax_element_proposed_tags_accept', array(
730
     $url_accept_paul = $this->generateUrl('ajax_element_proposed_tags_accept', array(
731
       'proposition_id' => $proposition_paul->getId(),
731
       'proposition_id' => $proposition_paul->getId(),
732
-      'token'          => $bux->getPersonalHash()
732
+      'token'          => $bux->getPersonalHash($proposition_paul->getId())
733
     ));
733
     ));
734
     $url_accept_joelle = $this->generateUrl('ajax_element_proposed_tags_accept', array(
734
     $url_accept_joelle = $this->generateUrl('ajax_element_proposed_tags_accept', array(
735
       'proposition_id' => $proposition_joelle->getId(),
735
       'proposition_id' => $proposition_joelle->getId(),
736
-      'token'          => $bux->getPersonalHash()
736
+      'token'          => $bux->getPersonalHash($proposition_joelle->getId())
737
     ));
737
     ));
738
     $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_paul.'"') !== false);
738
     $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_paul.'"') !== false);
739
     $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_joelle.'"') !== false);
739
     $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_joelle.'"') !== false);
740
     $url_refuse = $this->generateUrl('ajax_element_proposed_tags_refuse', array(
740
     $url_refuse = $this->generateUrl('ajax_element_proposed_tags_refuse', array(
741
       'element_id' => $element->getId(),
741
       'element_id' => $element->getId(),
742
-      'token'      => $bux->getPersonalHash()
742
+      'token'      => $bux->getPersonalHash($element->getId())
743
     ));
743
     ));
744
     
744
     
745
     // On accepete la poposition de joelle
745
     // On accepete la poposition de joelle
1099
     
1099
     
1100
     $url_accept_paul = $this->generateUrl('ajax_element_proposed_tags_accept', array(
1100
     $url_accept_paul = $this->generateUrl('ajax_element_proposed_tags_accept', array(
1101
       'proposition_id' => $proposition_paul->getId(),
1101
       'proposition_id' => $proposition_paul->getId(),
1102
-      'token'          => $bux->getPersonalHash()
1102
+      'token'          => $bux->getPersonalHash($proposition_paul->getId())
1103
     ));
1103
     ));
1104
     $url_accept_joelle = $this->generateUrl('ajax_element_proposed_tags_accept', array(
1104
     $url_accept_joelle = $this->generateUrl('ajax_element_proposed_tags_accept', array(
1105
       'proposition_id' => $proposition_joelle->getId(),
1105
       'proposition_id' => $proposition_joelle->getId(),
1106
-      'token'          => $bux->getPersonalHash()
1106
+      'token'          => $bux->getPersonalHash($proposition_joelle->getId())
1107
     ));
1107
     ));
1108
     $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_paul.'"') !== false);
1108
     $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_paul.'"') !== false);
1109
     $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_joelle.'"') !== false);
1109
     $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_joelle.'"') !== false);
1110
     $url_refuse = $this->generateUrl('ajax_element_proposed_tags_refuse', array(
1110
     $url_refuse = $this->generateUrl('ajax_element_proposed_tags_refuse', array(
1111
       'element_id' => $element->getId(),
1111
       'element_id' => $element->getId(),
1112
-      'token'      => $bux->getPersonalHash()
1112
+      'token'      => $bux->getPersonalHash($element->getId())
1113
     ));
1113
     ));
1114
     
1114
     
1115
     // On accepete la poposition de joelle
1115
     // On accepete la poposition de joelle

+ 14 - 14
src/Muzich/CoreBundle/Tests/Controller/EventTest.php View File

40
       'POST', 
40
       'POST', 
41
       $this->generateUrl('ajax_add_comment', array(
41
       $this->generateUrl('ajax_add_comment', array(
42
         'element_id' => $element->getId(),
42
         'element_id' => $element->getId(),
43
-        'token'      => $paul->getPersonalHash()
43
+        'token'      => $paul->getPersonalHash($element->getId())
44
       )), 
44
       )), 
45
       array(
45
       array(
46
           'comment' => "Du coup ce com va emettre un event"
46
           'comment' => "Du coup ce com va emettre un event"
77
       'POST', 
77
       'POST', 
78
       $this->generateUrl('ajax_add_comment', array(
78
       $this->generateUrl('ajax_add_comment', array(
79
         'element_id' => $element_2->getId(),
79
         'element_id' => $element_2->getId(),
80
-        'token'      => $paul->getPersonalHash()
80
+        'token'      => $paul->getPersonalHash($element_2->getId())
81
       )), 
81
       )), 
82
       array(
82
       array(
83
           'comment' => "Du coup ce com va aussi emettre un event"
83
           'comment' => "Du coup ce com va aussi emettre un event"
112
       'POST', 
112
       'POST', 
113
       $this->generateUrl('ajax_add_comment', array(
113
       $this->generateUrl('ajax_add_comment', array(
114
         'element_id' => $element_2->getId(),
114
         'element_id' => $element_2->getId(),
115
-        'token'      => $paul->getPersonalHash()
115
+        'token'      => $paul->getPersonalHash($element_2->getId())
116
       )), 
116
       )), 
117
       array(
117
       array(
118
           'comment' => "Du coup ce com va aussi emettre un event"
118
           'comment' => "Du coup ce com va aussi emettre un event"
247
     // Il ajoute cet élément en favoris
247
     // Il ajoute cet élément en favoris
248
     $url = $this->generateUrl('favorite_add', array(
248
     $url = $this->generateUrl('favorite_add', array(
249
       'id'    => $element->getId(),
249
       'id'    => $element->getId(),
250
-      'token' => $paul->getPersonalHash()
250
+      'token' => $paul->getPersonalHash($element->getId())
251
     ));
251
     ));
252
     
252
     
253
     $crawler = $this->client->request('GET', $url, array(), array(), array(
253
     $crawler = $this->client->request('GET', $url, array(), array(), array(
282
     // On enlève des favoris
282
     // On enlève des favoris
283
     $url = $this->generateUrl('favorite_remove', array(
283
     $url = $this->generateUrl('favorite_remove', array(
284
       'id'    => $element->getId(),
284
       'id'    => $element->getId(),
285
-      'token' => $paul->getPersonalHash()
285
+      'token' => $paul->getPersonalHash($element->getId())
286
     ));
286
     ));
287
     
287
     
288
     $crawler = $this->client->request('GET', $url, array(), array(), array(
288
     $crawler = $this->client->request('GET', $url, array(), array(), array(
349
       'POST', 
349
       'POST', 
350
       $this->generateUrl('ajax_add_comment', array(
350
       $this->generateUrl('ajax_add_comment', array(
351
         'element_id' => $element->getId(),
351
         'element_id' => $element->getId(),
352
-        'token'      => $paul->getPersonalHash()
352
+        'token'      => $paul->getPersonalHash($element->getId())
353
       )), 
353
       )), 
354
       array(
354
       array(
355
           'comment' => "Je choisis en commentant de suivre l'élément",
355
           'comment' => "Je choisis en commentant de suivre l'élément",
398
       'POST', 
398
       'POST', 
399
       $this->generateUrl('ajax_add_comment', array(
399
       $this->generateUrl('ajax_add_comment', array(
400
         'element_id' => $element->getId(),
400
         'element_id' => $element->getId(),
401
-        'token'      => $joelle->getPersonalHash()
401
+        'token'      => $joelle->getPersonalHash($element->getId())
402
       )), 
402
       )), 
403
       array(
403
       array(
404
           'comment' => "Je choisis en commentant de suivre l'élément (joelle)",
404
           'comment' => "Je choisis en commentant de suivre l'élément (joelle)",
447
       'POST', 
447
       'POST', 
448
       $this->generateUrl('ajax_add_comment', array(
448
       $this->generateUrl('ajax_add_comment', array(
449
         'element_id' => $element->getId(),
449
         'element_id' => $element->getId(),
450
-        'token'      => $bux->getPersonalHash()
450
+        'token'      => $bux->getPersonalHash($element->getId())
451
       )), 
451
       )), 
452
       array(
452
       array(
453
           'comment' => "Voila le com qui declenche les événemetns chez paul et joelle"
453
           'comment' => "Voila le com qui declenche les événemetns chez paul et joelle"
499
       'POST', 
499
       'POST', 
500
       $this->generateUrl('ajax_add_comment', array(
500
       $this->generateUrl('ajax_add_comment', array(
501
         'element_id' => $element->getId(),
501
         'element_id' => $element->getId(),
502
-        'token'      => $bux->getPersonalHash()
502
+        'token'      => $bux->getPersonalHash($element->getId())
503
       )), 
503
       )), 
504
       array(
504
       array(
505
           'comment' => "un nouveau com"
505
           'comment' => "un nouveau com"
589
       'POST', 
589
       'POST', 
590
       $this->generateUrl('ajax_add_comment', array(
590
       $this->generateUrl('ajax_add_comment', array(
591
         'element_id' => $element->getId(),
591
         'element_id' => $element->getId(),
592
-        'token'      => $paul->getPersonalHash()
592
+        'token'      => $paul->getPersonalHash($element->getId())
593
       )), 
593
       )), 
594
       array(
594
       array(
595
           'comment' => "ze veux plus",
595
           'comment' => "ze veux plus",
657
       'POST', 
657
       'POST', 
658
       $this->generateUrl('ajax_add_comment', array(
658
       $this->generateUrl('ajax_add_comment', array(
659
         'element_id' => $element->getId(),
659
         'element_id' => $element->getId(),
660
-        'token'      => $bux->getPersonalHash()
660
+        'token'      => $bux->getPersonalHash($element->getId())
661
       )), 
661
       )), 
662
       array(
662
       array(
663
           'comment' => "ce com va declencher un event chez joelle mais pas chez paul"
663
           'comment' => "ce com va declencher un event chez joelle mais pas chez paul"
734
     $url_follow = $this->generateUrl('follow', array(
734
     $url_follow = $this->generateUrl('follow', array(
735
       'type' => 'user', 
735
       'type' => 'user', 
736
       'id' => $bob->getId(),
736
       'id' => $bob->getId(),
737
-      'token' => $bux->getPersonalHash()
737
+      'token' => $bux->getPersonalHash($bob->getId())
738
     ));
738
     ));
739
     
739
     
740
     $this->crawler = $this->client->request('GET', $url_follow);
740
     $this->crawler = $this->client->request('GET', $url_follow);
898
       $this->generateUrl('ajax_element_proposed_tags_accept', 
898
       $this->generateUrl('ajax_element_proposed_tags_accept', 
899
         array(
899
         array(
900
           'proposition_id' => $proposition_id,
900
           'proposition_id' => $proposition_id,
901
-          'token' => $user->getPersonalHash()
901
+          'token' => $user->getPersonalHash($proposition_id)
902
         )
902
         )
903
       ), 
903
       ), 
904
       array(), 
904
       array(), 
919
       $this->generateUrl('ajax_element_proposed_tags_refuse', 
919
       $this->generateUrl('ajax_element_proposed_tags_refuse', 
920
         array(
920
         array(
921
           'element_id' => $element_id,
921
           'element_id' => $element_id,
922
-          'token' => $user->getPersonalHash()
922
+          'token' => $user->getPersonalHash($element_id)
923
         )
923
         )
924
       ), 
924
       ), 
925
       array(), 
925
       array(), 

+ 4 - 4
src/Muzich/CoreBundle/Tests/Controller/FavoriteControllerTest.php View File

153
     $this->exist('li:contains("DUDELDRUM")');
153
     $this->exist('li:contains("DUDELDRUM")');
154
     $this->exist('a[href="'.($url = $this->generateUrl('favorite_add', array(
154
     $this->exist('a[href="'.($url = $this->generateUrl('favorite_add', array(
155
       'id'    => $element_DUDELDRUM->getId(),
155
       'id'    => $element_DUDELDRUM->getId(),
156
-      'token' => $this->getUser()->getPersonalHash()
156
+      'token' => $this->getUser()->getPersonalHash($element_DUDELDRUM->getId())
157
     ))).'"]');
157
     ))).'"]');
158
     $link = $this->selectLink('a[href="'.$url.'"]');
158
     $link = $this->selectLink('a[href="'.$url.'"]');
159
     $this->clickOnLink($link);
159
     $this->clickOnLink($link);
169
     // Il a laissé place aux lien pour le retirer
169
     // Il a laissé place aux lien pour le retirer
170
     $this->exist('a[href="'.($url_rm = $this->generateUrl('favorite_remove', array(
170
     $this->exist('a[href="'.($url_rm = $this->generateUrl('favorite_remove', array(
171
       'id'    => $element_DUDELDRUM->getId(),
171
       'id'    => $element_DUDELDRUM->getId(),
172
-      'token' => $this->getUser()->getPersonalHash()
172
+      'token' => $this->getUser()->getPersonalHash($element_DUDELDRUM->getId())
173
     ))).'"]');
173
     ))).'"]');
174
     
174
     
175
     // En base l'enregistrement existe
175
     // En base l'enregistrement existe
232
     // Il ajoute cet élément en favoris
232
     // Il ajoute cet élément en favoris
233
     $url = $this->generateUrl('favorite_add', array(
233
     $url = $this->generateUrl('favorite_add', array(
234
       'id'    => $element->getId(),
234
       'id'    => $element->getId(),
235
-      'token' => $bux->getPersonalHash()
235
+      'token' => $bux->getPersonalHash($element->getId())
236
     ));
236
     ));
237
     
237
     
238
     $crawler = $this->client->request('GET', $url, array(), array(), array(
238
     $crawler = $this->client->request('GET', $url, array(), array(), array(
257
     // On enlève des favoris
257
     // On enlève des favoris
258
     $url = $this->generateUrl('favorite_remove', array(
258
     $url = $this->generateUrl('favorite_remove', array(
259
       'id'    => $element->getId(),
259
       'id'    => $element->getId(),
260
-      'token' => $bux->getPersonalHash()
260
+      'token' => $bux->getPersonalHash($element->getId())
261
     ));
261
     ));
262
     
262
     
263
     $crawler = $this->client->request('GET', $url, array(), array(), array(
263
     $crawler = $this->client->request('GET', $url, array(), array(), array(

+ 1 - 1
src/Muzich/CoreBundle/Tests/Controller/GroupControllerTest.php View File

84
             
84
             
85
     $this->exist('a[href="'.($url = $this->generateUrl('group_delete', array(
85
     $this->exist('a[href="'.($url = $this->generateUrl('group_delete', array(
86
       'group_id'  => $Fans_de_psytrance->getId(),
86
       'group_id'  => $Fans_de_psytrance->getId(),
87
-      'token'     => $this->getUser()->getPersonalHash()
87
+      'token'     => $this->getUser()->getPersonalHash($Fans_de_psytrance->getId())
88
     ))).'"]');
88
     ))).'"]');
89
     
89
     
90
     $this->crawler = $this->client->request('GET', $url);
90
     $this->crawler = $this->client->request('GET', $url);

+ 3 - 3
src/Muzich/CoreBundle/Tests/Controller/HomeControllerTest.php View File

844
         'name' => $fan_de_psy->getName(),
844
         'name' => $fan_de_psy->getName(),
845
         'id'   => $fan_de_psy->getId(),
845
         'id'   => $fan_de_psy->getId(),
846
         'url'  => $this->generateUrl('ajax_set_element_group', array(
846
         'url'  => $this->generateUrl('ajax_set_element_group', array(
847
-          'token'      => $this->getUser()->getPersonalHash(),
847
+          'token'      => $this->getUser()->getPersonalHash($element->getId()),
848
           'element_id' => $element->getId(),
848
           'element_id' => $element->getId(),
849
           'group_id'   => $fan_de_psy->getId()
849
           'group_id'   => $fan_de_psy->getId()
850
         ))
850
         ))
857
       $this->generateUrl('ajax_set_element_group', array(
857
       $this->generateUrl('ajax_set_element_group', array(
858
         'element_id' => $element->getId(),
858
         'element_id' => $element->getId(),
859
         'group_id'   => $fan_de_psy->getId(),
859
         'group_id'   => $fan_de_psy->getId(),
860
-        'token'      => $this->getUser()->getPersonalHash()
860
+        'token'      => $this->getUser()->getPersonalHash($element->getId())
861
       )), 
861
       )), 
862
       array(), 
862
       array(), 
863
       array(), 
863
       array(), 
960
     // On accepte la proposition de paul
960
     // On accepte la proposition de paul
961
     $url_accept_paul = $this->generateUrl('ajax_element_proposed_tags_accept', array(
961
     $url_accept_paul = $this->generateUrl('ajax_element_proposed_tags_accept', array(
962
       'proposition_id' => $proposition_paul->getId(),
962
       'proposition_id' => $proposition_paul->getId(),
963
-      'token'          => $bux->getPersonalHash()
963
+      'token'          => $bux->getPersonalHash($proposition_paul->getId())
964
     ));
964
     ));
965
     
965
     
966
     $crawler = $this->client->request(
966
     $crawler = $this->client->request(

+ 7 - 7
src/Muzich/CoreBundle/Tests/Controller/ModerateControllerTest.php View File

29
     // Paul signale cet élément comme pas bien
29
     // Paul signale cet élément comme pas bien
30
     $url = $this->generateUrl('ajax_report_element', array(
30
     $url = $this->generateUrl('ajax_report_element', array(
31
       'element_id' => $element_ed->getId(),
31
       'element_id' => $element_ed->getId(),
32
-      'token'      => $paul->getPersonalHash()
32
+      'token'      => $paul->getPersonalHash($element_ed->getId())
33
     ));
33
     ));
34
     
34
     
35
     $crawler = $this->client->request(
35
     $crawler = $this->client->request(
57
     // Ca ne doit pas bouger puisqu'il l'a déjà fait
57
     // Ca ne doit pas bouger puisqu'il l'a déjà fait
58
     $url = $this->generateUrl('ajax_report_element', array(
58
     $url = $this->generateUrl('ajax_report_element', array(
59
       'element_id' => $element_ed->getId(),
59
       'element_id' => $element_ed->getId(),
60
-      'token'      => $paul->getPersonalHash()
60
+      'token'      => $paul->getPersonalHash($element_ed->getId())
61
     ));
61
     ));
62
     
62
     
63
     $crawler = $this->client->request(
63
     $crawler = $this->client->request(
96
     // Ca ne doit pas bouger puisqu'il l'a déjà fait
96
     // Ca ne doit pas bouger puisqu'il l'a déjà fait
97
     $url = $this->generateUrl('ajax_report_element', array(
97
     $url = $this->generateUrl('ajax_report_element', array(
98
       'element_id' => $element_bab->getId(),
98
       'element_id' => $element_bab->getId(),
99
-      'token'      => $paul->getPersonalHash()
99
+      'token'      => $paul->getPersonalHash($element_bab->getId())
100
     ));
100
     ));
101
     
101
     
102
     $crawler = $this->client->request(
102
     $crawler = $this->client->request(
136
     // Paul signale cet élément comme pas bien
136
     // Paul signale cet élément comme pas bien
137
     $url = $this->generateUrl('ajax_report_element', array(
137
     $url = $this->generateUrl('ajax_report_element', array(
138
       'element_id' => $element_ed->getId(),
138
       'element_id' => $element_ed->getId(),
139
-      'token'      => $joelle->getPersonalHash()
139
+      'token'      => $joelle->getPersonalHash($element_ed->getId())
140
     ));
140
     ));
141
     
141
     
142
     $crawler = $this->client->request(
142
     $crawler = $this->client->request(
164
     // Ca ne doit pas bouger puisqu'elle l'a déjà fait
164
     // Ca ne doit pas bouger puisqu'elle l'a déjà fait
165
     $url = $this->generateUrl('ajax_report_element', array(
165
     $url = $this->generateUrl('ajax_report_element', array(
166
       'element_id' => $element_ed->getId(),
166
       'element_id' => $element_ed->getId(),
167
-      'token'      => $joelle->getPersonalHash()
167
+      'token'      => $joelle->getPersonalHash($element_ed->getId())
168
     ));
168
     ));
169
     
169
     
170
     $crawler = $this->client->request(
170
     $crawler = $this->client->request(
318
       $this->generateUrl('ajax_alert_comment', array(
318
       $this->generateUrl('ajax_alert_comment', array(
319
         'element_id' => $element->getId(),
319
         'element_id' => $element->getId(),
320
         'date'       => $comment_bux['d'],
320
         'date'       => $comment_bux['d'],
321
-        'token'      => $joelle->getPersonalHash()
321
+        'token'      => $joelle->getPersonalHash($element->getId())
322
       )),
322
       )),
323
       array(), 
323
       array(), 
324
       array(), 
324
       array(), 
348
       $this->generateUrl('ajax_alert_comment', array(
348
       $this->generateUrl('ajax_alert_comment', array(
349
         'element_id' => $element->getId(),
349
         'element_id' => $element->getId(),
350
         'date'       => $comment_paul['d'],
350
         'date'       => $comment_paul['d'],
351
-        'token'      => $joelle->getPersonalHash()
351
+        'token'      => $joelle->getPersonalHash($element->getId())
352
       )),
352
       )),
353
       array(), 
353
       array(), 
354
       array(), 
354
       array(), 

+ 2 - 2
src/Muzich/CoreBundle/Tests/Controller/MynetworkControllerTest.php View File

125
     $url_follow = $this->generateUrl('follow', array(
125
     $url_follow = $this->generateUrl('follow', array(
126
       'type' => 'user', 
126
       'type' => 'user', 
127
       'id' => $bux->getId(),
127
       'id' => $bux->getId(),
128
-      'token' => $this->getUser()->getPersonalHash()
128
+      'token' => $this->getUser()->getPersonalHash($bux->getId())
129
     ));
129
     ));
130
     
130
     
131
     // On lance l'action de suivre
131
     // On lance l'action de suivre
210
     $url_follow = $this->generateUrl('follow', array(
210
     $url_follow = $this->generateUrl('follow', array(
211
       'type' => 'group', 
211
       'type' => 'group', 
212
       'id' => $DUDELDRUM->getId(),
212
       'id' => $DUDELDRUM->getId(),
213
-      'token' => $this->getUser()->getPersonalHash()
213
+      'token' => $this->getUser()->getPersonalHash($DUDELDRUM->getId())
214
     ));
214
     ));
215
     
215
     
216
     // On lance l'action de suivre
216
     // On lance l'action de suivre

+ 3 - 2
src/Muzich/CoreBundle/Tests/Controller/ReputationTest.php View File

59
       'GET', 
59
       'GET', 
60
       $this->generateUrl('ajax_element_add_vote_good', array(
60
       $this->generateUrl('ajax_element_add_vote_good', array(
61
         'element_id' => $element->getId(),
61
         'element_id' => $element->getId(),
62
-        'token' => $paul->getPersonalHash()
62
+        'token' => $paul->getPersonalHash($element->getId())
63
       )), 
63
       )), 
64
       array(), 
64
       array(), 
65
       array(), 
65
       array(), 
83
     $crawler = $this->client->request(
83
     $crawler = $this->client->request(
84
       'GET', 
84
       'GET', 
85
       $this->generateUrl('element_remove', array(
85
       $this->generateUrl('element_remove', array(
86
-        'element_id' => $element->getId()
86
+        'element_id' => $element->getId(),
87
+        'token'      => $bux->getPersonalHash($element->getId())
87
       )), 
88
       )), 
88
       array(), 
89
       array(), 
89
       array(), 
90
       array(), 

+ 4 - 4
src/Muzich/CoreBundle/Tests/Controller/ShowControllerTest.php View File

228
     
228
     
229
     $url = $this->generateUrl('favorite_add', array(
229
     $url = $this->generateUrl('favorite_add', array(
230
       'id'    => $element->getId(),
230
       'id'    => $element->getId(),
231
-      'token' => $bux->getPersonalHash()
231
+      'token' => $bux->getPersonalHash($element->getId())
232
     ));
232
     ));
233
     
233
     
234
     $crawler = $this->client->request('GET', $url, array(), array(), array(
234
     $crawler = $this->client->request('GET', $url, array(), array(), array(
273
     
273
     
274
     $url = $this->generateUrl('favorite_add', array(
274
     $url = $this->generateUrl('favorite_add', array(
275
       'id'    => $element->getId(),
275
       'id'    => $element->getId(),
276
-      'token' => $bux->getPersonalHash()
276
+      'token' => $bux->getPersonalHash($element->getId())
277
     ));
277
     ));
278
     
278
     
279
     $crawler = $this->client->request('GET', $url, array(), array(), array(
279
     $crawler = $this->client->request('GET', $url, array(), array(), array(
322
     
322
     
323
     $url = $this->generateUrl('favorite_add', array(
323
     $url = $this->generateUrl('favorite_add', array(
324
       'id'    => $element->getId(),
324
       'id'    => $element->getId(),
325
-      'token' => $joelle->getPersonalHash()
325
+      'token' => $joelle->getPersonalHash($element->getId())
326
     ));
326
     ));
327
     
327
     
328
     $crawler = $this->client->request('GET', $url, array(), array(), array(
328
     $crawler = $this->client->request('GET', $url, array(), array(), array(
367
     
367
     
368
     $url = $this->generateUrl('favorite_add', array(
368
     $url = $this->generateUrl('favorite_add', array(
369
       'id'    => $element->getId(),
369
       'id'    => $element->getId(),
370
-      'token' => $joelle->getPersonalHash()
370
+      'token' => $joelle->getPersonalHash($element->getId())
371
     ));
371
     ));
372
     
372
     
373
     $crawler = $this->client->request('GET', $url, array(), array(), array(
373
     $crawler = $this->client->request('GET', $url, array(), array(), array(

+ 1 - 1
src/Muzich/CoreBundle/Tests/Controller/TagsTest.php View File

51
     // Il ajoute cet élément en favoris
51
     // Il ajoute cet élément en favoris
52
     $url = $this->generateUrl('favorite_add', array(
52
     $url = $this->generateUrl('favorite_add', array(
53
       'id'    => $element->getId(),
53
       'id'    => $element->getId(),
54
-      'token' => $paul->getPersonalHash()
54
+      'token' => $paul->getPersonalHash($element->getId())
55
     ));
55
     ));
56
     
56
     
57
     $crawler = $this->client->request('GET', $url, array(), array(), array(
57
     $crawler = $this->client->request('GET', $url, array(), array(), array(

+ 3 - 3
src/Muzich/CoreBundle/Tests/Controller/UserControllerTest.php View File

375
     
375
     
376
     $url = $this->generateUrl('ajax_tag_add_to_favorites', array(
376
     $url = $this->generateUrl('ajax_tag_add_to_favorites', array(
377
       'tag_id' => $tribe->getId(),
377
       'tag_id' => $tribe->getId(),
378
-      'token'  => $paul->getPersonalHash()
378
+      'token'  => $paul->getPersonalHash($tribe->getId())
379
     ));
379
     ));
380
     
380
     
381
     $crawler = $this->client->request('GET', $url, array(), array(), array(
381
     $crawler = $this->client->request('GET', $url, array(), array(), array(
400
     
400
     
401
     $url = $this->generateUrl('ajax_tag_add_to_favorites', array(
401
     $url = $this->generateUrl('ajax_tag_add_to_favorites', array(
402
       'tag_id' => $tribe->getId(),
402
       'tag_id' => $tribe->getId(),
403
-      'token'  => $paul->getPersonalHash()
403
+      'token'  => $paul->getPersonalHash($tribe->getId())
404
     ));
404
     ));
405
     
405
     
406
     $crawler = $this->client->request('GET', $url, array(), array(), array(
406
     $crawler = $this->client->request('GET', $url, array(), array(), array(
425
     
425
     
426
     $url = $this->generateUrl('ajax_tag_add_to_favorites', array(
426
     $url = $this->generateUrl('ajax_tag_add_to_favorites', array(
427
       'tag_id' => $hardtek->getId(),
427
       'tag_id' => $hardtek->getId(),
428
-      'token'  => $paul->getPersonalHash()
428
+      'token'  => $paul->getPersonalHash($hardtek->getId())
429
     ));
429
     ));
430
     
430
     
431
     $crawler = $this->client->request('GET', $url, array(), array(), array(
431
     $crawler = $this->client->request('GET', $url, array(), array(), array(

+ 1 - 1
src/Muzich/CoreBundle/lib/Controller.php View File

479
               'name' => $group->getName(),
479
               'name' => $group->getName(),
480
               'id'   => $group->getId(),
480
               'id'   => $group->getId(),
481
               'url'  => $this->generateUrl('ajax_set_element_group', array(
481
               'url'  => $this->generateUrl('ajax_set_element_group', array(
482
-                'token'      => $this->getUser()->getPersonalHash(),
482
+                'token'      => $this->getUser()->getPersonalHash($element->getId()),
483
                 'element_id' => $element->getId(),
483
                 'element_id' => $element->getId(),
484
                 'group_id'   => $group->getId()
484
                 'group_id'   => $group->getId()
485
               ))
485
               ))

+ 4 - 4
src/Muzich/FavoriteBundle/Controller/FavoriteController.php View File

47
     
47
     
48
     $em = $this->getEntityManager();
48
     $em = $this->getEntityManager();
49
     
49
     
50
-    if ($user->getPersonalHash() != $token || !is_numeric($id)
50
+    if ($user->getPersonalHash($id) != $token || !is_numeric($id)
51
       || !($element = $em->getRepository('MuzichCoreBundle:Element')->findOneById($id))
51
       || !($element = $em->getRepository('MuzichCoreBundle:Element')->findOneById($id))
52
     )
52
     )
53
     {
53
     {
88
         'favorite'      => true,
88
         'favorite'      => true,
89
         'link_new_url'  => $this->generateUrl('favorite_remove', array(
89
         'link_new_url'  => $this->generateUrl('favorite_remove', array(
90
             'id'    => $id,
90
             'id'    => $id,
91
-            'token' => $token
91
+            'token' => $user->getPersonalHash($id)
92
         )),
92
         )),
93
         'img_new_src'   => $this->getAssetUrl('img/icon_star_2_red.png'),
93
         'img_new_src'   => $this->getAssetUrl('img/icon_star_2_red.png'),
94
         'img_new_title' => $this->trans('element.favorite.remove', array(), 'elements')
94
         'img_new_title' => $this->trans('element.favorite.remove', array(), 'elements')
116
     $user = $this->getUser();
116
     $user = $this->getUser();
117
     $em = $this->getDoctrine()->getEntityManager();
117
     $em = $this->getDoctrine()->getEntityManager();
118
     
118
     
119
-    if ($user->getPersonalHash() != $token || !is_numeric($id)
119
+    if ($user->getPersonalHash($id) != $token || !is_numeric($id)
120
       || !($element = $em->getRepository('MuzichCoreBundle:Element')->findOneById($id))
120
       || !($element = $em->getRepository('MuzichCoreBundle:Element')->findOneById($id))
121
     )
121
     )
122
     {
122
     {
151
         'favorite'      => true,
151
         'favorite'      => true,
152
         'link_new_url'  => $this->generateUrl('favorite_add', array(
152
         'link_new_url'  => $this->generateUrl('favorite_add', array(
153
             'id'    => $id,
153
             'id'    => $id,
154
-            'token' => $token
154
+            'token' => $user->getPersonalHash($id)
155
         )),
155
         )),
156
         'img_new_src'   => $this->getAssetUrl('img/icon_star_2.png'),
156
         'img_new_src'   => $this->getAssetUrl('img/icon_star_2.png'),
157
         'img_new_title' => $this->trans('element.favorite.add', array(), 'elements')
157
         'img_new_title' => $this->trans('element.favorite.add', array(), 'elements')

+ 1 - 1
src/Muzich/GroupBundle/Controller/DefaultController.php View File

201
   public function deleteAction($group_id, $token)
201
   public function deleteAction($group_id, $token)
202
   {
202
   {
203
     $user = $this->getUser();
203
     $user = $this->getUser();
204
-    if ($user->getPersonalHash() != $token)
204
+    if ($user->getPersonalHash($group_id) != $token)
205
     {
205
     {
206
       throw $this->createNotFoundException('Accès non autorisé.');
206
       throw $this->createNotFoundException('Accès non autorisé.');
207
     }
207
     }

+ 1 - 1
src/Muzich/GroupBundle/Resources/views/Default/myList.html.twig View File

29
         <a href="{{ path('show_group', { 'slug': group.slug }) }}">{{ group.name }}</a>
29
         <a href="{{ path('show_group', { 'slug': group.slug }) }}">{{ group.name }}</a>
30
         
30
         
31
         <a title="{{ 'group.remove.link'|trans({}, 'groups') }}" class="group_remove_link" 
31
         <a title="{{ 'group.remove.link'|trans({}, 'groups') }}" class="group_remove_link" 
32
-          href="{{ path('group_delete', {'group_id' : group.id, 'token': app.user.personalHash})  }}"
32
+          href="{{ path('group_delete', {'group_id' : group.id, 'token': app.user.personalHash(group.id)})  }}"
33
         >
33
         >
34
           <img src="{{ asset('bundles/muzichcore/img/1327168960_fileclose.png') }}" alt="delete" />
34
           <img src="{{ asset('bundles/muzichcore/img/1327168960_fileclose.png') }}" alt="delete" />
35
         </a>
35
         </a>

+ 1 - 1
src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig View File

19
         </a>
19
         </a>
20
       {% endif %}
20
       {% endif %}
21
       
21
       
22
-      <a href="{{ path('follow', { 'type': 'group', 'id': group.id, 'token': user.personalHash }) }}" 
22
+      <a href="{{ path('follow', { 'type': 'group', 'id': group.id, 'token': user.personalHash(group.id) }) }}" 
23
          class="follow_link button darkbutton {% if following %}following{% else %}notfollowing{% endif %}">
23
          class="follow_link button darkbutton {% if following %}following{% else %}notfollowing{% endif %}">
24
         {% if following %}
24
         {% if following %}
25
           {{ 'group.following'|trans({}, 'groups') }}
25
           {{ 'group.following'|trans({}, 'groups') }}

+ 1 - 1
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig View File

14
     <div class="show_options">
14
     <div class="show_options">
15
             
15
             
16
       {% if app.user.id != viewed_user.id %}
16
       {% if app.user.id != viewed_user.id %}
17
-        <a href="{{ path('follow', { 'type': 'user', 'id': viewed_user.id, 'token': user.personalHash }) }}" 
17
+        <a href="{{ path('follow', { 'type': 'user', 'id': viewed_user.id, 'token': user.personalHash(viewed_user.id) }) }}" 
18
            class="follow_link button darkbutton {% if following %}following{% else %}notfollowing{% endif %}" >
18
            class="follow_link button darkbutton {% if following %}following{% else %}notfollowing{% endif %}" >
19
           {% if following %}
19
           {% if following %}
20
             {{ 'user.following'|trans({}, 'users') }}
20
             {{ 'user.following'|trans({}, 'users') }}