mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-15 06:09:58 +08:00
use Validate class in setup
This commit is contained in:
parent
8b9d902908
commit
baeb967857
@ -12,12 +12,15 @@ class Validate
|
||||
* @param array $keys
|
||||
* @return void
|
||||
*/
|
||||
public static function checkPost(Array $keys)
|
||||
public static function checkPost(Array $keys, $silent = false)
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
if (!isset($_POST[$key]))
|
||||
if (!isset($_POST[$key])) {
|
||||
if ($silent) return false;
|
||||
throw new E('Invalid parameters.', 1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function email($email)
|
||||
@ -42,11 +45,13 @@ class Validate
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function password($password)
|
||||
public static function password($password, $silent = false)
|
||||
{
|
||||
if (strlen($password) > 16 || strlen($password) < 8) {
|
||||
if ($silent) return false;
|
||||
throw new E('无效的密码。密码长度应该大于 8 并小于 16。', 2);
|
||||
} else if (Utils::convertString($password) != $password) {
|
||||
if ($silent) return false;
|
||||
throw new E('无效的密码。密码中包含了奇怪的字符。', 2);
|
||||
}
|
||||
return true;
|
||||
|
@ -46,7 +46,7 @@ switch ($step) {
|
||||
|
||||
case 3:
|
||||
// check post
|
||||
if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['confirm-pwd']))
|
||||
if (Validate::checkPost(['email', 'password', 'confirm-pwd']))
|
||||
{
|
||||
if ($_POST['password'] != $_POST['confirm-pwd'])
|
||||
Http::redirect('index.php?step=2', '确认密码不一致');
|
||||
@ -55,8 +55,8 @@ switch ($step) {
|
||||
$password = $_POST['password'];
|
||||
$sitename = isset($_POST['sitename']) ? $_POST['sitename'] : "Blessing Skin Server";
|
||||
|
||||
if (Validate::checkValidEmail($email)) {
|
||||
if (strlen($password) > 16 || strlen($password) < 8) {
|
||||
if (Validate::email($email)) {
|
||||
if (!Validate::password($password)) {
|
||||
Http::redirect('index.php?step=2', '无效的密码。密码长度应该大于 8 并小于 16。');
|
||||
|
||||
} else if (Utils::convertString($password) != $password) {
|
||||
|
Loading…
Reference in New Issue
Block a user