add gui_access flag to admins and customers to allow/disallow login to the webui; fixes #1219

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2024-01-07 10:23:02 +01:00
parent 9c23013777
commit 284def5832
12 changed files with 113 additions and 28 deletions

View File

@@ -146,6 +146,8 @@ class Admins extends ApiCommand implements ResourceEntity
* optional, default auto-generated
* @param string $def_language
* optional, default is system-default language
* @param bool $gui_access
* optional, allow login via webui, if false ONLY the login via webui is disallowed; default true
* @param bool $api_allowed
* optional, default is true if system setting api.enabled is true, else false
* @param string $custom_notes
@@ -219,6 +221,7 @@ class Admins extends ApiCommand implements ResourceEntity
// parameters
$def_language = $this->getParam('def_language', true, Settings::Get('panel.standardlanguage'));
$gui_access = $this->getBoolParam('gui_access', true, true);
$api_allowed = $this->getBoolParam('api_allowed', true, Settings::Get('api.enabled'));
$custom_notes = $this->getParam('custom_notes', true, '');
$custom_notes_show = $this->getBoolParam('custom_notes_show', true, 0);
@@ -316,6 +319,7 @@ class Admins extends ApiCommand implements ResourceEntity
'name' => $name,
'email' => $email,
'lang' => $def_language,
'gui_access' => $gui_access,
'api_allowed' => $api_allowed,
'change_serversettings' => $change_serversettings,
'customers' => $customers,
@@ -344,6 +348,7 @@ class Admins extends ApiCommand implements ResourceEntity
`name` = :name,
`email` = :email,
`def_language` = :lang,
`gui_access` = :gui_access,
`api_allowed` = :api_allowed,
`change_serversettings` = :change_serversettings,
`customers` = :customers,
@@ -431,6 +436,8 @@ class Admins extends ApiCommand implements ResourceEntity
* optional, default auto-generated
* @param string $def_language
* optional, default is system-default language
* @param bool $gui_access
* * optional, allow login via webui, if false ONLY the login via webui is disallowed; default true
* @param bool $api_allowed
* optional, default is true if system setting api.enabled is true, else false
* @param string $custom_notes
@@ -524,6 +531,7 @@ class Admins extends ApiCommand implements ResourceEntity
// you cannot edit some of the details of yourself
if ($result['adminid'] == $this->getUserDetail('adminid')) {
$gui_access = $result['gui_access'];
$api_allowed = $result['api_allowed'];
$deactivated = $result['deactivated'];
$customers = $result['customers'];
@@ -542,6 +550,7 @@ class Admins extends ApiCommand implements ResourceEntity
$traffic = $result['traffic'];
$ipaddress = ($result['ip'] != -1 ? json_decode($result['ip'], true) : -1);
} else {
$gui_access = $this->getBoolParam('gui_access', true, $result['gui_access']);
$api_allowed = $this->getBoolParam('api_allowed', true, $result['api_allowed']);
$deactivated = $this->getBoolParam('deactivated', true, $result['deactivated']);
@@ -665,6 +674,7 @@ class Admins extends ApiCommand implements ResourceEntity
'name' => $name,
'email' => $email,
'lang' => $def_language,
'gui_access' => $gui_access,
'api_allowed' => $api_allowed,
'change_serversettings' => $change_serversettings,
'customers' => $customers,
@@ -694,6 +704,7 @@ class Admins extends ApiCommand implements ResourceEntity
`name` = :name,
`email` = :email,
`def_language` = :lang,
`gui_access` = :gui_access,
`api_allowed` = :api_allowed,
`change_serversettings` = :change_serversettings,
`customers` = :customers,

View File

@@ -191,6 +191,8 @@ class Customers extends ApiCommand implements ResourceEntity
* optional
* @param string $def_language ,
* optional, default is system-default language
* @param bool $gui_access
* optional, allow login via webui, if false ONLY the login via webui is disallowed; default true
* @param bool $api_allowed
* optional, default is true if system setting api.enabled is true, else false
* @param int $gender
@@ -297,6 +299,7 @@ class Customers extends ApiCommand implements ResourceEntity
$fax = $this->getParam('fax', true, '');
$customernumber = $this->getParam('customernumber', true, '');
$def_language = $this->getParam('def_language', true, Settings::Get('panel.standardlanguage'));
$gui_access = $this->getBoolParam('gui_access', true, 1);
$api_allowed = $this->getBoolParam('api_allowed', true, (Settings::Get('api.enabled') && Settings::Get('api.customer_default')));
$gender = (int)$this->getParam('gender', true, 0);
$custom_notes = $this->getParam('custom_notes', true, '');
@@ -515,6 +518,7 @@ class Customers extends ApiCommand implements ResourceEntity
'email' => $email,
'customerno' => $customernumber,
'lang' => $def_language,
'gui_access' => $gui_access,
'api_allowed' => $api_allowed,
'docroot' => $documentroot,
'guid' => $guid,
@@ -557,6 +561,7 @@ class Customers extends ApiCommand implements ResourceEntity
`email` = :email,
`customernumber` = :customerno,
`def_language` = :lang,
`gui_access` = :gui_access,
`api_allowed` = :api_allowed,
`documentroot` = :docroot,
`guid` = :guid,
@@ -948,6 +953,8 @@ class Customers extends ApiCommand implements ResourceEntity
* optional
* @param string $def_language ,
* optional, default is system-default language
* @param bool $gui_access
* optional, allow login via webui, if false ONLY the login via webui is disallowed; default true
* @param bool $api_allowed
* optional, default is true if system setting api.enabled is true, else false
* @param int $gender
@@ -1062,6 +1069,7 @@ class Customers extends ApiCommand implements ResourceEntity
$fax = $this->getParam('fax', true, $result['fax']);
$customernumber = $this->getParam('customernumber', true, $result['customernumber']);
$def_language = $this->getParam('def_language', true, $result['def_language']);
$gui_access = $this->getBoolParam('gui_access', true, $result['gui_access']);
$api_allowed = $this->getBoolParam('api_allowed', true, $result['api_allowed']);
$gender = (int)$this->getParam('gender', true, $result['gender']);
$custom_notes = $this->getParam('custom_notes', true, $result['custom_notes']);
@@ -1396,6 +1404,7 @@ class Customers extends ApiCommand implements ResourceEntity
'logviewenabled' => $logviewenabled,
'custom_notes' => $custom_notes,
'custom_notes_show' => $custom_notes_show,
'gui_access' => $gui_access,
'api_allowed' => $api_allowed,
'allowed_mysqlserver' => empty($allowed_mysqlserver) ? "" : json_encode($allowed_mysqlserver)
];
@@ -1439,6 +1448,7 @@ class Customers extends ApiCommand implements ResourceEntity
`logviewenabled` = :logviewenabled,
`custom_notes` = :custom_notes,
`custom_notes_show` = :custom_notes_show,
`gui_access` = :gui_access,
`api_allowed` = :api_allowed,
`allowed_mysqlserver` = :allowed_mysqlserver";
$upd_query .= $admin_upd_query;

View File

@@ -64,6 +64,13 @@ return [
'selected' => $userinfo['language']
],
'gui_access' => [
'label' => lng('usersettings.gui_access.title'),
'desc' => lng('usersettings.gui_access.description'),
'type' => 'checkbox',
'value' => '1',
'checked' => 1,
],
'api_allowed' => [
'label' => lng('usersettings.api_allowed.title'),
'desc' => lng('usersettings.api_allowed.description'),
@@ -71,7 +78,7 @@ return [
'value' => '1',
'checked' => Settings::Get('api.enabled') == '1',
'visible' => Settings::Get('api.enabled') == '1'
]
],
]
],
'section_b' => [

View File

@@ -71,6 +71,14 @@ return [
'selected' => $result['def_language'],
'visible' => $result['adminid'] != $userinfo['userid']
],
'gui_access' => [
'label' => lng('usersettings.gui_access.title'),
'desc' => lng('usersettings.gui_access.description'),
'type' => 'checkbox',
'value' => '1',
'checked' => $result['gui_access'],
'visible' => $result['adminid'] != $userinfo['userid']
],
'api_allowed' => [
'label' => lng('usersettings.api_allowed.title'),
'desc' => lng('usersettings.api_allowed.description'),
@@ -78,7 +86,7 @@ return [
'value' => '1',
'checked' => $result['api_allowed'],
'visible' => Settings::Get('api.enabled') == '1'
]
],
]
],
'section_b' => [

View File

@@ -82,6 +82,13 @@ return [
'select_var' => Language::getLanguages(),
'selected' => Settings::Get('panel.standardlanguage')
],
'gui_access' => [
'label' => lng('usersettings.gui_access.title'),
'desc' => lng('usersettings.gui_access.description'),
'type' => 'checkbox',
'value' => '1',
'checked' => 1
],
'api_allowed' => [
'label' => lng('usersettings.api_allowed.title'),
'desc' => lng('usersettings.api_allowed.description'),

View File

@@ -80,6 +80,13 @@ return [
'select_var' => Language::getLanguages(),
'selected' => $result['def_language']
],
'gui_access' => [
'label' => lng('usersettings.gui_access.title'),
'desc' => lng('usersettings.gui_access.description'),
'type' => 'checkbox',
'value' => '1',
'checked' => $result['gui_access'],
],
'api_allowed' => [
'label' => lng('usersettings.api_allowed.title'),
'desc' => lng('usersettings.api_allowed.description'),

View File

@@ -50,20 +50,20 @@ return [
'callback' => [Email::class, 'account'],
],
'm.spam_tag_level' => [
'label' => lng('emails.spam_tag_level'),
'label' => lng('antispam.spam_tag_level.title'),
'field' => 'spam_tag_level',
],
'm.spam_kill_level' => [
'label' => lng('emails.spam_kill_level'),
'label' => lng('antispam.spam_kill_level.title'),
'field' => 'spam_kill_level',
],
'm.bypass_spam' => [
'label' => lng('emails.bypass_spam'),
'label' => lng('antispam.bypass_spam.title'),
'field' => 'bypass_spam',
'callback' => [Text::class, 'boolean'],
],
'm.policy_greylist' => [
'label' => lng('emails.policy_greylist'),
'label' => lng('antispam.policy_greylist.title'),
'field' => 'policy_greylist',
'callback' => [Text::class, 'boolean'],
],