Login password min length, boolean default set if empty

Also remove all inserts from the table declaration and add them in a
separate file instead

Add add/remove css to element for the element js declarations
This commit is contained in:
Clemens Schwaighofer
2018-07-04 18:58:07 +09:00
parent e3d1679f86
commit bddc196e25
32 changed files with 99 additions and 159 deletions

View File

@@ -263,6 +263,30 @@ function ael(base, attach, id = '')
// DESC : resets the sub elements of the base element given
const rel = (base) => base.sub = [];
// METHOD: rcssel [remove a css from the element]
// PARAMS: element, style sheet to remove
// RETURN: "none", in place because of reference
// DESC : searches and removes style from css array
function rcssel(element, css)
{
let css_index = element.css.indexOf(css);
if (css_index > -1) {
element.css.splice(css_index, 1);
}
}
// METHOD acssel [add css element]
// PARAMS: element, style sheet to add
// RETURN: "none", in place add because of reference
// DESC : adds a new style sheet to the element given
function acssel(element, css)
{
let css_index = element.css.indexOf(css);
if (css_index > -1) {
element.css.push(css);
}
}
// METHOD: phfo [produce html from object]
// PARAMS: object tree with dom element declarations
// RETURN: HTML string that can be used as innerHTML

View File

@@ -75,7 +75,9 @@ class Login extends \CoreLibs\DB\IO
private $pw_change_deny_users = array (); // array of users for which the password change is forbidden
// if we have password change we need to define some rules
private $password_min_length = 8;
private $password_min_length = PASSWORD_MIN_LENGTH;
// max length is fixed as 255 (for input type max), if set highter, it will be set back to 255
private $password_max_length = PASSWORD_MAX_LENGTH;
// can have several regexes, if nothing set, all is ok
private $password_valid_chars = array (
// '^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,}$',
@@ -119,6 +121,16 @@ class Login extends \CoreLibs\DB\IO
exit;
}
// pre-check that password min/max lengths are inbetween 1 and 255;
if ($this->password_max_length > 255) {
echo "<b>Settings problem</b> PMaL<br>";
exit;
}
if ($this->password_min_length < 1) {
echo "<b>Settings problem</b> PMiL<br>";
exit;
}
$this->l = new \CoreLibs\Language\L10n($lang);
// if we have a search path we need to set it, to use the correct DB to login
@@ -729,12 +741,28 @@ class Login extends \CoreLibs\DB\IO
}
}
// check for min length
if (strlen($password) < $this->password_min_length) {
if (strlen($password) < $this->password_min_length || strlen($password) > $this->password_max_length) {
$is_valid_password = false;
}
return $is_valid_password;
}
// METHOD: loginSetPasswordMinLength
// PARAMS: set the minimum length
// RETURN: true/false on success
// DESC : sets the minium length and checks on valid
public function loginSetPasswordMinLength($length)
{
// check that numeric, positive numeric, not longer than max input string lenght
// and not short than min password length
if (is_numeric($length) && $length >= PASSWORD_MIN_LENGTH && $length <= $this->password_max_length) {
$this->password_min_length = $length;
return true;
} else {
return false;
}
}
// METHOD: loginPasswordChange
// WAS : login_password_change
// PARAMS: none

View File

@@ -1341,7 +1341,7 @@ class Basic
// METHOD: compareDate
// WAS : CompareDate
// PARAMS: start_date, end_date (both: YYYY-MM-DD)
// RETURN: -1 if the first date is smaller the last, 0 if both are equal, 1 if the end date is bigger than the last
// RETURN: -1 if the first date is smaller the last, 0 if both are equal, 1 if the first date is bigger than the last
// DESC : splits & checks date, wrap around for check_date function
public static function compareDate($start_date, $end_date)
{

View File

@@ -1621,6 +1621,12 @@ class IO extends \CoreLibs\Basic
if ($string == 'f' || $string == 'false') {
return false;
}
// fallback in case top is not t/f, default on set unset
if ($string) {
return true;
} else {
return false;
}
} else {
if ($string) {
return 't';