forked from ZwiiCMS-Team/ZwiiCMS
Faille csrf user delete edit
This commit is contained in:
parent
d3fa8c76b6
commit
bae3ad464d
@ -88,13 +88,10 @@ class user extends common {
|
|||||||
* Suppression
|
* Suppression
|
||||||
*/
|
*/
|
||||||
public function delete() {
|
public function delete() {
|
||||||
//
|
|
||||||
// $url prend l'adresse sans le token
|
|
||||||
$url = explode('&',$this->getUrl(2));
|
|
||||||
// Accès refusé
|
// Accès refusé
|
||||||
if(
|
if(
|
||||||
// L'utilisateur n'existe pas
|
// L'utilisateur n'existe pas
|
||||||
$this->getData(['user', $url[0]]) === null
|
$this->getData(['user', $this->getUrl(2)]) === null
|
||||||
// Groupe insuffisant
|
// Groupe insuffisant
|
||||||
AND ($this->getUrl('group') < self::GROUP_MODERATOR)
|
AND ($this->getUrl('group') < self::GROUP_MODERATOR)
|
||||||
) {
|
) {
|
||||||
@ -104,14 +101,14 @@ class user extends common {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Jeton incorrect
|
// Jeton incorrect
|
||||||
elseif(!isset($_GET['csrf'])) {
|
elseif(!$this->getUrl(3)) {
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . 'user',
|
'redirect' => helper::baseUrl() . 'user',
|
||||||
'notification' => 'Jeton invalide'
|
'notification' => 'Jeton invalide'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
elseif ($this->getUrl(3) !== $_SESSION['csrf']) {
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . 'user',
|
'redirect' => helper::baseUrl() . 'user',
|
||||||
@ -119,7 +116,7 @@ class user extends common {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Bloque la suppression de son propre compte
|
// Bloque la suppression de son propre compte
|
||||||
elseif($this->getUser('id') === $url[0]) {
|
elseif($this->getUser('id') === $this->getUrl(2)) {
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . 'user',
|
'redirect' => helper::baseUrl() . 'user',
|
||||||
@ -128,7 +125,7 @@ class user extends common {
|
|||||||
}
|
}
|
||||||
// Suppression
|
// Suppression
|
||||||
else {
|
else {
|
||||||
$this->deleteData(['user', $url[0]]);
|
$this->deleteData(['user', $this->getUrl(2)]);
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . 'user',
|
'redirect' => helper::baseUrl() . 'user',
|
||||||
@ -162,6 +159,21 @@ class user extends common {
|
|||||||
'access' => false
|
'access' => false
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
// Jeton incorrect
|
||||||
|
if(!$this->getUrl(4)) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'user',
|
||||||
|
'notification' => 'Jeton invalide'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
elseif ($this->getUrl(4) !== $_SESSION['csrf']) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'user',
|
||||||
|
'notification' => 'Suppression non autorisée'
|
||||||
|
]);
|
||||||
|
}
|
||||||
// Accès autorisé
|
// Accès autorisé
|
||||||
else {
|
else {
|
||||||
// Soumission du formulaire
|
// Soumission du formulaire
|
||||||
@ -293,12 +305,12 @@ class user extends common {
|
|||||||
$userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']),
|
$userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']),
|
||||||
self::$groups[$this->getData(['user', $userId, 'group'])],
|
self::$groups[$this->getData(['user', $userId, 'group'])],
|
||||||
template::button('userEdit' . $userId, [
|
template::button('userEdit' . $userId, [
|
||||||
'href' => helper::baseUrl() . 'user/edit/' . $userId . '/back',
|
'href' => helper::baseUrl() . 'user/edit/' . $userId . '/back/'. $_SESSION['csrf'],
|
||||||
'value' => template::ico('pencil')
|
'value' => template::ico('pencil')
|
||||||
]),
|
]),
|
||||||
template::button('userDelete' . $userId, [
|
template::button('userDelete' . $userId, [
|
||||||
'class' => 'userDelete buttonRed',
|
'class' => 'userDelete buttonRed',
|
||||||
'href' => helper::baseUrl() . 'user/delete/' . $userId. '&csrf=' . $_SESSION['csrf'],
|
'href' => helper::baseUrl() . 'user/delete/' . $userId. '/' . $_SESSION['csrf'],
|
||||||
'value' => template::ico('cancel')
|
'value' => template::ico('cancel')
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user