Skip to content

Commit 4e9afd3

Browse files
author
wrongecho
committed
Certificates - perms and model
Move certificates to the new permissions system Deduplicate add/edit using a model
1 parent c352f6e commit 4e9afd3

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

post/user/certificate.php

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,9 @@
66

77
if (isset($_POST['add_certificate'])) {
88

9-
validateTechRole();
9+
enforceUserPermission('module_support', 2);
1010

11-
$client_id = intval($_POST['client_id']);
12-
$name = sanitizeInput($_POST['name']);
13-
$description = sanitizeInput($_POST['description']);
14-
$domain = sanitizeInput($_POST['domain']);
15-
$issued_by = sanitizeInput($_POST['issued_by']);
16-
$expire = sanitizeInput($_POST['expire']);
17-
$public_key = sanitizeInput($_POST['public_key']);
18-
$notes = sanitizeInput($_POST['notes']);
19-
$domain_id = intval($_POST['domain_id']);
11+
require_once 'post/user/certificate_model.php';
2012

2113
// Parse public key data for a manually provided public key
2214
if (!empty($public_key) && (empty($expire) && empty($issued_by))) {
@@ -49,18 +41,10 @@
4941

5042
if (isset($_POST['edit_certificate'])) {
5143

52-
validateTechRole();
44+
enforceUserPermission('module_support', 2);
5345

46+
require_once 'post/user/certificate_model.php';
5447
$certificate_id = intval($_POST['certificate_id']);
55-
$name = sanitizeInput($_POST['name']);
56-
$description = sanitizeInput($_POST['description']);
57-
$domain = sanitizeInput($_POST['domain']);
58-
$issued_by = sanitizeInput($_POST['issued_by']);
59-
$expire = sanitizeInput($_POST['expire']);
60-
$public_key = sanitizeInput($_POST['public_key']);
61-
$notes = sanitizeInput($_POST['notes']);
62-
$domain_id = intval($_POST['domain_id']);
63-
$client_id = intval($_POST['client_id']);
6448

6549
// Parse public key data for a manually provided public key
6650
if (!empty($public_key) && (empty($expire) && empty($issued_by))) {
@@ -91,7 +75,7 @@
9175

9276
if (isset($_GET['archive_certificate'])) {
9377

94-
validateTechRole();
78+
enforceUserPermission('module_support', 2);
9579

9680
$certificate_id = intval($_GET['archive_certificate']);
9781

@@ -115,7 +99,7 @@
11599

116100
if (isset($_GET['delete_certificate'])) {
117101

118-
validateAdminRole();
102+
enforceUserPermission('module_support', 3);
119103

120104
$certificate_id = intval($_GET['delete_certificate']);
121105

@@ -138,7 +122,7 @@
138122
}
139123

140124
if (isset($_POST['bulk_delete_certificates'])) {
141-
validateAdminRole();
125+
enforceUserPermission('module_support', 3);
142126
validateCSRFToken($_POST['csrf_token']);
143127

144128
$count = 0; // Default 0
@@ -169,7 +153,7 @@
169153

170154
if (isset($_POST['export_client_certificates_csv'])) {
171155

172-
validateTechRole();
156+
enforceUserPermission('module_support');
173157

174158
$client_id = intval($_POST['client_id']);
175159

0 commit comments

Comments
 (0)