mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 05:13:54 -07:00
Added password required symbols check (#713)
* Added password required symbols check * Update Validate.php
This commit is contained in:
parent
ab77976e10
commit
6e4c8a1b88
3 changed files with 43 additions and 1 deletions
|
@ -372,6 +372,15 @@ $bb_cfg['unique_ip'] = false; // Запретить регистрацию не
|
||||||
$bb_cfg['new_user_reg_restricted'] = false; // Ограничить регистрацию новых пользователей по времени по указанному ниже интервалу
|
$bb_cfg['new_user_reg_restricted'] = false; // Ограничить регистрацию новых пользователей по времени по указанному ниже интервалу
|
||||||
$bb_cfg['new_user_reg_interval'] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]; // Допустимые часы регистрации
|
$bb_cfg['new_user_reg_interval'] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]; // Допустимые часы регистрации
|
||||||
$bb_cfg['reg_email_activation'] = true; // Требовать активацию учетной записи по email
|
$bb_cfg['reg_email_activation'] = true; // Требовать активацию учетной записи по email
|
||||||
|
$bb_cfg['password_symbols'] = [
|
||||||
|
// Требовать наличие символов в пароле
|
||||||
|
'nums' => true, // Цифры
|
||||||
|
'spec_symbols' => false, // Спец. символы
|
||||||
|
'letters' => [ // Буквы
|
||||||
|
'uppercase' => true, // Заглавные буквы
|
||||||
|
'lowercase' => true // Строчные буквы
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
// Email
|
// Email
|
||||||
$bb_cfg['emailer'] = [
|
$bb_cfg['emailer'] = [
|
||||||
|
|
|
@ -1461,6 +1461,10 @@ $lang['CHOOSE_PASS'] = 'Field for the password must not be empty!';
|
||||||
$lang['CHOOSE_PASS_ERR'] = 'Entered passwords do not match';
|
$lang['CHOOSE_PASS_ERR'] = 'Entered passwords do not match';
|
||||||
$lang['CHOOSE_PASS_ERR_MIN'] = 'Your password must be at least %d characters';
|
$lang['CHOOSE_PASS_ERR_MIN'] = 'Your password must be at least %d characters';
|
||||||
$lang['CHOOSE_PASS_ERR_MAX'] = 'Your password must be no longer than $d characters';
|
$lang['CHOOSE_PASS_ERR_MAX'] = 'Your password must be no longer than $d characters';
|
||||||
|
$lang['CHOOSE_PASS_ERR_NUM'] = 'The password must contain at least one digit';
|
||||||
|
$lang['CHOOSE_PASS_ERR_LETTER'] = 'The password must contain at least one letter of the Latin alphabet';
|
||||||
|
$lang['CHOOSE_PASS_ERR_LETTER_UPPERCASE'] = 'The password must contain at least one uppercase letter of the Latin alphabet';
|
||||||
|
$lang['CHOOSE_PASS_ERR_SPEC_SYMBOL'] = 'The password must contain at least one special character';
|
||||||
$lang['CHOOSE_PASS_OK'] = 'Passwords match';
|
$lang['CHOOSE_PASS_OK'] = 'Passwords match';
|
||||||
$lang['CHOOSE_PASS_REG_OK'] = 'Passwords match, you can proceed with the registration';
|
$lang['CHOOSE_PASS_REG_OK'] = 'Passwords match, you can proceed with the registration';
|
||||||
$lang['CHOOSE_PASS_FAILED'] = 'To change the password, you must correctly specify the current password';
|
$lang['CHOOSE_PASS_FAILED'] = 'To change the password, you must correctly specify the current password';
|
||||||
|
|
|
@ -16,6 +16,8 @@ use Egulias\EmailValidator\Validation\RFCValidation;
|
||||||
use Egulias\EmailValidator\Validation\MessageIDValidation;
|
use Egulias\EmailValidator\Validation\MessageIDValidation;
|
||||||
use Egulias\EmailValidator\Validation\Extra\SpoofCheckValidation;
|
use Egulias\EmailValidator\Validation\Extra\SpoofCheckValidation;
|
||||||
|
|
||||||
|
use TorrentPier\Helpers\IsHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Validate
|
* Class Validate
|
||||||
* @package TorrentPier
|
* @package TorrentPier
|
||||||
|
@ -168,7 +170,7 @@ class Validate
|
||||||
*/
|
*/
|
||||||
public static function password(string $password, string $password_confirm)
|
public static function password(string $password, string $password_confirm)
|
||||||
{
|
{
|
||||||
global $lang;
|
global $lang, $bb_cfg;
|
||||||
|
|
||||||
// Check for empty
|
// Check for empty
|
||||||
if (empty($password) || empty($password_confirm)) {
|
if (empty($password) || empty($password_confirm)) {
|
||||||
|
@ -188,6 +190,33 @@ class Validate
|
||||||
return sprintf($lang['CHOOSE_PASS_ERR_MIN'], PASSWORD_MIN_LENGTH);
|
return sprintf($lang['CHOOSE_PASS_ERR_MIN'], PASSWORD_MIN_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Symbols check
|
||||||
|
if ($bb_cfg['password_symbols']) {
|
||||||
|
// Numbers
|
||||||
|
if ($bb_cfg['password_symbols']['nums']) {
|
||||||
|
if (!IsHelper::isContainsNums($password)) {
|
||||||
|
return $lang['CHOOSE_PASS_ERR_NUM'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Letters
|
||||||
|
if ($bb_cfg['password_symbols']['letters']['lowercase']) {
|
||||||
|
if (!IsHelper::isContainsLetters($password)) {
|
||||||
|
return $lang['CHOOSE_PASS_ERR_LETTER'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($bb_cfg['password_symbols']['letters']['uppercase']) {
|
||||||
|
if (!IsHelper::isContainsLetters($password, true)) {
|
||||||
|
return $lang['CHOOSE_PASS_ERR_LETTER_UPPERCASE'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Spec symbols
|
||||||
|
if ($bb_cfg['password_symbols']['spec_symbols']) {
|
||||||
|
if (!IsHelper::isContainsSpecSymbols($password)) {
|
||||||
|
return $lang['CHOOSE_PASS_ERR_SPEC_SYMBOL'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue