Skip to content
Snippets Groups Projects
Commit 1cd3fe9c authored by Moritz Strohm's avatar Moritz Strohm Committed by Jan-Hendrik Willms
Browse files

use CSRF protection when creating/editing/deleting an OER material, fixes #3268

Closes #3268

Merge request studip/studip!2210
parent 0cd702f3
No related branches found
No related tags found
No related merge requests found
......@@ -28,12 +28,14 @@ class Oer_MymaterialController extends AuthenticatedController
$content_types = ['application/x-zip-compressed', 'application/zip', 'application/x-zip'];
$tmp_folder = $GLOBALS['TMP_PATH'] . '/temp_folder_' . md5(uniqid());
if (Request::submitted('delete') && Request::isPost()) {
CSRFProtection::verifyUnsafeRequest();
$material->pushDataToIndexServers('delete');
$material->delete();
PageLayout::postSuccess(_('Das Material wurde gelöscht.'));
$this->redirect('oer/market/index');
return;
} elseif (Request::isPost()) {
CSRFProtection::verifyUnsafeRequest();
$was_new = $material->isNew();
$was_on_twillo = (bool) $material['published_id_on_twillo'];
$data = Request::getArray('data');
......
......@@ -73,6 +73,7 @@
<? if (!$material['host_id'] && ($material->isMine() || $GLOBALS['perm']->have_perm("root"))) : ?>
<?= \Studip\LinkButton::create(_('Bearbeiten'), $controller->link_for("oer/mymaterial/edit/".$material->getId()), ['data-dialog' => "1"]) ?>
<form action="<?= $controller->link_for("oer/mymaterial/edit/".$material->getId()) ?>" method="post" style="display: inline;">
<?= CSRFProtection::tokenTag() ?>
<?= \Studip\Button::create(_('Löschen'), "delete", ['value' => 1, 'data-confirm' => _('Wirklich löschen?')]) ?>
</form>
<? endif ?>
......
......@@ -4,7 +4,7 @@
onsubmit="$(window).off('beforeunload')"
data-secure
enctype="multipart/form-data">
<?= CSRFProtection::tokenTag() ?>
<div class="oercampus_editmaterial">
<fieldset>
<legend><?= _('Grunddaten') ?></legend>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment