Browse Source

Fix double link creation see BT#12235

jmontoyaa 8 years ago
parent
commit
32e6a5ef38
1 changed files with 4 additions and 2 deletions
  1. 4 2
      main/link/link.php

+ 4 - 2
main/link/link.php

@@ -99,14 +99,16 @@ $show = isset($_REQUEST['show']) && in_array(trim($_REQUEST['show']), ['all', 'n
 $categoryId = isset($_REQUEST['category_id']) ? intval($_REQUEST['category_id']) : '';
 $linkListUrl = api_get_self().'?'.api_get_cidreq().'&category_id='.$categoryId.'&show='.$show;
 $content = '';
+$token = Security::get_existing_token();
 
 switch ($action) {
     case 'addlink':
         if (api_is_allowed_to_edit(null, true)) {
-            $form = Link::getLinkForm(null, 'addlink');
-            if ($form->validate()) {
+            $form = Link::getLinkForm(null, 'addlink', $token);
+            if ($form->validate() && Security::check_token('get')) {
                 // Here we add a link
                 Link::addlinkcategory("link");
+                Security::clear_token();
                 header('Location: '.$linkListUrl);
                 exit;
             }