From: Marcin Haba Date: Fri, 1 Jan 2016 08:48:57 +0000 (+0100) Subject: baculum: Tweak fields validation in initial wizard X-Git-Tag: Release-7.4.0~54 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=edd099666293212421283bca7558903d79aaeb22;p=bacula%2Fbacula baculum: Tweak fields validation in initial wizard --- diff --git a/gui/baculum/protected/Class/ConfigurationManager.php b/gui/baculum/protected/Class/ConfigurationManager.php index b5692817bb..db22b11468 100644 --- a/gui/baculum/protected/Class/ConfigurationManager.php +++ b/gui/baculum/protected/Class/ConfigurationManager.php @@ -43,6 +43,11 @@ class ConfigurationManager extends TModule */ const USERS_FILE = 'Application.Data.baculum'; + /** + * User name allowed characters pattern + */ + const USER_PATTERN = '[a-zA-Z0-9]+'; + /** * PostgreSQL default params */ @@ -71,6 +76,7 @@ class ConfigurationManager extends TModule /** * Get database name by database type (short name). + * * @access public * @param string $type database type ('pgsql', 'mysql' ...) * @return mixed database name or null if database name not found @@ -88,6 +94,7 @@ class ConfigurationManager extends TModule /** * Check if given database type is PostgreSQL type. + * * @access public * @param string $type database type ('pgsql', 'mysql' ...) * @return boolean true if database type is PostgreSQL, otherwise false @@ -98,6 +105,7 @@ class ConfigurationManager extends TModule /** * Check if given database type is MySQL type. + * * @access public * @param string $type database type ('pgsql', 'mysql' ...) * @return boolean true if database type is MySQL, otherwise false @@ -108,6 +116,7 @@ class ConfigurationManager extends TModule /** * Check if given database type is SQLite type. + * * @access public * @param string $type database type ('sqlite', 'mysql' ...) * @return boolean true if database type is SQLite, otherwise false @@ -119,6 +128,7 @@ class ConfigurationManager extends TModule /** * Get currently set application language short name. * If no language set then default language is taken. + * * @access public * @return string lanuage short name */ @@ -135,6 +145,7 @@ class ConfigurationManager extends TModule /** * Save application configuration. + * * @access public * @param array $config structure of config file params * @return boolean true if config save is successfully, false if config save is failure @@ -146,6 +157,7 @@ class ConfigurationManager extends TModule /** * Get application configuration. + * * @access public * @return array application configuration */ @@ -156,6 +168,7 @@ class ConfigurationManager extends TModule /** * Check if application configuration file exists. + * * @access public * @return boolean true if file exists, otherwise false */ @@ -163,6 +176,16 @@ class ConfigurationManager extends TModule return file_exists(Prado::getPathOfNamespace(self::CONFIG_FILE, '.conf')); } + /** + * Get user name allowed characters pattern + * + * @access public + * @return string user name pattern + */ + public function getUserPattern() { + return self::USER_PATTERN; + } + /** * Get encrypted password to use in HTTP Basic auth. * @@ -284,6 +307,7 @@ class ConfigurationManager extends TModule /** * Check if users configuration file exists. + * * @access public * @return boolean true if file exists, otherwise false */ @@ -293,6 +317,7 @@ class ConfigurationManager extends TModule /** * Clear all content of users file. + * * @access public * @return boolean true if file cleared successfully, otherwise false */ @@ -320,6 +345,15 @@ class ConfigurationManager extends TModule public function switchToUser($http_protocol, $host, $port, $user, $password) { $urlPrefix = $this->Application->getModule('friendly-url')->getUrlPrefix(); $location = sprintf("%s://%s:%s@%s:%d%s", $http_protocol, $user, $password, $host, $port, $urlPrefix); + $refresh_url = sprintf("%s://%s:%d%s", $http_protocol, $host, $port, $urlPrefix); + + /** + * Refresh page is required due to lack of auth data in $_SERVER superglobal array + * after re-login by URI. + */ + $_SESSION['refresh_page'] = $refresh_url; + + // Log in by header header("Location: $location"); } diff --git a/gui/baculum/protected/Lang/en/messages.mo b/gui/baculum/protected/Lang/en/messages.mo index 4ffd86e024..53838bef85 100644 Binary files a/gui/baculum/protected/Lang/en/messages.mo and b/gui/baculum/protected/Lang/en/messages.mo differ diff --git a/gui/baculum/protected/Lang/en/messages.po b/gui/baculum/protected/Lang/en/messages.po index 1179348a93..714dd39455 100644 --- a/gui/baculum/protected/Lang/en/messages.po +++ b/gui/baculum/protected/Lang/en/messages.po @@ -1130,3 +1130,6 @@ msgstr "Username:" msgid "Please note that for each user (excluding administrator) there should exist separate Bconsole config file in form:" msgstr "Please note that for each user (excluding administrator) there should exist separate Bconsole config file in form:" +msgid "Invalid login value. Login may contain a-z A-Z 0-9 characters." +msgstr "Invalid login value. Login may contain a-z A-Z 0-9 characters." + diff --git a/gui/baculum/protected/Lang/pl/messages.mo b/gui/baculum/protected/Lang/pl/messages.mo index 5b082983cc..b748100927 100644 Binary files a/gui/baculum/protected/Lang/pl/messages.mo and b/gui/baculum/protected/Lang/pl/messages.mo differ diff --git a/gui/baculum/protected/Lang/pl/messages.po b/gui/baculum/protected/Lang/pl/messages.po index ae77299db4..774876fb35 100644 --- a/gui/baculum/protected/Lang/pl/messages.po +++ b/gui/baculum/protected/Lang/pl/messages.po @@ -1131,3 +1131,6 @@ msgstr "Nazwa użytkownika:" msgid "Please note that for each user (excluding administrator) there should exist separate Bconsole config file in form:" msgstr "Uwaga! Dla każdego użytkownika (wyłączając administratora) powinien istnieć osobny plik konfiguracyjny Bconsole w postaci:" +msgid "Invalid login value. Login may contain a-z A-Z 0-9 characters." +msgstr "Niepoprawny login. Login może zawierać znaki z zakresu: a-z A-Z 0-9" + diff --git a/gui/baculum/protected/Pages/ConfigurationWizard.page b/gui/baculum/protected/Pages/ConfigurationWizard.page index 2568fb78b0..b0ca6c48e5 100644 --- a/gui/baculum/protected/Pages/ConfigurationWizard.page +++ b/gui/baculum/protected/Pages/ConfigurationWizard.page @@ -61,7 +61,7 @@ - + @@ -70,7 +70,7 @@

- +
@@ -84,7 +84,7 @@ - + @@ -92,14 +92,14 @@
- +
- +
@@ -110,21 +110,21 @@
- +
- +
- +
@@ -147,7 +147,7 @@ <%[ Loading... ]%> Validate <%[ OK ]%> - Invalidate <%[ Connection error ]%> + Invalidate <%[ Connection error ]%> @@ -162,14 +162,14 @@
- +
- +
@@ -198,7 +198,7 @@ <%[ Loading... ]%> Validate <%[ OK ]%> - Invalidate <%[ Connection error ]%> + Invalidate <%[ Connection error ]%> @@ -218,7 +218,7 @@
- +
@@ -231,24 +231,25 @@
- + +
- - + +
- - - + + +
diff --git a/gui/baculum/protected/Pages/ConfigurationWizard.php b/gui/baculum/protected/Pages/ConfigurationWizard.php index 8be23c600a..d9a4e498ba 100644 --- a/gui/baculum/protected/Pages/ConfigurationWizard.php +++ b/gui/baculum/protected/Pages/ConfigurationWizard.php @@ -32,6 +32,7 @@ class ConfigurationWizard extends BaculumPage { public $firstRun; public $applicationConfig; + public $userPattern; const DEFAULT_DB_NAME = 'bacula'; const DEFAULT_DB_LOGIN = 'bacula'; @@ -42,8 +43,10 @@ class ConfigurationWizard extends BaculumPage public function onInit($param) { parent::onInit($param); $this->Lang->SelectedValue = $_SESSION['language']; - $this->firstRun = !$this->getModule('configuration')->isApplicationConfig(); - $this->applicationConfig = $this->getModule('configuration')->getApplicationConfig(); + $config = $this->getModule('configuration'); + $this->firstRun = !$config->isApplicationConfig(); + $this->applicationConfig = $config->getApplicationConfig(); + $this->userPattern = $config->getUserPattern(); if($this->firstRun === false && $this->User->getIsAdmin() === false) { die('Access denied.'); } @@ -112,6 +115,7 @@ class ConfigurationWizard extends BaculumPage if($this->getModule('configuration')->isUsersConfig() === true) { // version with users config file, so next is try to auto-login $previousUser = ($this->firstRun === false) ? $this->applicationConfig['baculum']['login'] : null; $this->getModule('configuration')->setUsersConfig($cfgData['baculum']['login'], $cfgData['baculum']['password'], $this->firstRun, $previousUser); + // Automatic login after finish wizard. $http_protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https' : 'http'; $this->getModule('configuration')->switchToUser($http_protocol, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $cfgData['baculum']['login'], $cfgData['baculum']['password']); diff --git a/gui/baculum/themes/Baculum-v1/style.css b/gui/baculum/themes/Baculum-v1/style.css index 57a0789bb7..23cc8c0757 100644 --- a/gui/baculum/themes/Baculum-v1/style.css +++ b/gui/baculum/themes/Baculum-v1/style.css @@ -376,7 +376,7 @@ div.actions_btn { } .line { - height: 35px; + min-height: 35px; clear: both; } @@ -397,12 +397,16 @@ div.actions_btn { width: 98%; } -.validator, .validate { +.validator, .validate, .validator-block { color: #e3454b !important; font-size: 10pt; /*margin-left: 5px;*/ } +.validator-block { + display: block; +} + .validate { color: #96c600 !important; } @@ -873,6 +877,7 @@ fieldset { } fieldset .line { + min-height: initial; height: 25px; }