From a8d218d17419d97670da262a7843b6450e1637cf Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 14 Dec 2015 21:59:25 +0100 Subject: [PATCH] (legacy) remoev duplicate cert code from usermanager (use redirect instead), closes https://github.com/opnsense/core/issues/59 --- src/www/system_usermanager.php | 132 ++++----------------------------- 1 file changed, 13 insertions(+), 119 deletions(-) diff --git a/src/www/system_usermanager.php b/src/www/system_usermanager.php index 61af4219d..a0a8bb3cd 100644 --- a/src/www/system_usermanager.php +++ b/src/www/system_usermanager.php @@ -161,7 +161,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } $pconfig = $_POST; - if ($act == "deluser" && isset($id)) { // drop user local_user_del($a_user[$id]); @@ -239,21 +238,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $reqdfields = explode(" ", "usernamefld"); $reqdfieldsn = array(gettext("Username")); } else { - if (empty($pconfig['name'])) { - $reqdfields = explode(" ", "usernamefld passwordfld1"); - $reqdfieldsn = array( - gettext("Username"), - gettext("Password")); - } else { - $reqdfields = explode(" ", "usernamefld passwordfld1 name caref keylen lifetime"); - $reqdfieldsn = array( - gettext("Username"), - gettext("Password"), - gettext("Descriptive name"), - gettext("Certificate authority"), - gettext("Key length"), - gettext("Lifetime")); - } + $reqdfields = explode(" ", "usernamefld passwordfld1"); + $reqdfieldsn = array( + gettext("Username"), + gettext("Password")); } do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); @@ -354,37 +342,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { if (isset($id)) { $a_user[$id] = $userent; } else { - if (!empty($pconfig['name'])) { - $cert = array(); - $cert['refid'] = uniqid(); - $userent['cert'] = array(); - - $cert['descr'] = $pconfig['name']; - - $subject = cert_get_subject_array($ca['crt']); - - $dn = array( - 'countryName' => $subject[0]['v'], - 'stateOrProvinceName' => $subject[1]['v'], - 'localityName' => $subject[2]['v'], - 'organizationName' => $subject[3]['v'], - 'emailAddress' => $subject[4]['v'], - 'commonName' => $userent['name']); - - cert_create( - $cert, - $pconfig['caref'], - $pconfig['keylen'], - (int)$pconfig['lifetime'], - $dn - ); - - if (!is_array($config['cert'])) { - $config['cert'] = array(); - } - $config['cert'][] = $cert; - $userent['cert'][] = $cert['refid']; - } $userent['uid'] = $config['system']['nextuid']++; /* Add the user to All Users group. */ foreach ($config['system']['group'] as $gidx => $group) { @@ -404,8 +361,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { local_user_set_groups($userent, $pconfig['groups']); write_config(); - header("Location: system_usermanager.php"); - exit; + if (!empty($pconfig['chkNewCert'])) { + // redirect to cert manager when a new cert is requested for this user + header("Location: system_certmanager.php?act=new&userid=".(count($a_user)-1)); + } else { + header("Location: system_usermanager.php"); + exit; + } } } elseif (isset($id)) { header("Location: system_usermanager.php?userid=".$id); @@ -558,12 +520,6 @@ $( document ).ready(function() { }); }); - // checkbox, add new cert for new user - $("#chkNewCert").click(function(){ - $("#usercertchck").toggleClass('hidden visible'); - $("#usercert").toggleClass('hidden visible'); - }); - // expand ssh key section on click $("#authorizedkeys").click(function(){ $(this).attr('rows', '7'); @@ -933,76 +889,14 @@ $( document ).ready(function() { 0) : - $i = 0; - foreach ($config['ca'] as $ca) { - if (!$ca['prv']) { - continue; - } - $i++; - } -?> + else :?> - - - - - - 0) :?> - - - - - - - - - - - - - - - - - - - - -
- -
- -
() - -
() - -
+ ()