Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
refactor(Validator): Add function buildDefaultValue()
Browse files Browse the repository at this point in the history
Signed-off-by: Rhilip <rhilipruan@gmail.com>
  • Loading branch information
Rhilip committed Jun 15, 2019
1 parent e580577 commit d263c6c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
### Feat
- **Auth:** Add full Advanced Options for Login
- **Auth:** Add UserRecover Form
- **Cleanup:** Add disable cleanup job by set priority to 0
- **Cleanup:** Cleanup dead peers
- **Cleanup:** Add disable cleanup job by set priority to 0
- **Debug:** Remove DebugMiddleware
- **Debug:** Add extend debug output
- **Email:** Add email template
- **Form Validator:** Add library bootstrap-validator library
- **Frontend:** Add localforage As Cache Provider
- **Invite:** Add base invite table
- **Invite:** Finish invite system
- **News:** Fix news tag not appear in index
Expand All @@ -32,6 +33,7 @@
- **Admin Panel:** Fix index num in Redis Keys Page
- **Auth:** Fix Broken Auth page after frontend framework change
- **DATABASE:** Fix CURRENT_TIMESTAMP Extra error
- **Email:** Fix Email Can't Send
- **Error:** Fix Error Handler
- **Invite:** Add Fine-grained control of recycle pending
- **Register:** Add captcha checker
Expand Down
11 changes: 5 additions & 6 deletions apps/models/form/UserRegisterForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ class UserRegisterForm extends Validator

protected $_action = 'register';

public function setData($config)
{
parent::setData($config);
$this->buildDefaultValue();
}

public function buildDefaultValue()
{
$this->status = app()->config->get('register.user_default_status') ?? User::STATUS_PENDING;
Expand Down Expand Up @@ -152,6 +146,9 @@ public function isValidUsername()
return;
}

// TODO Check if this username is not in blacklist

// Check this username is exist in Table `users` or not
$count = app()->pdo->createCommand("SELECT COUNT(`id`) FROM `users` WHERE `username` = :username")->bindParams([
"username" => $username
])->queryScalar();
Expand Down Expand Up @@ -182,6 +179,8 @@ public function isValidEmail()
}
}

// TODO Check if this email is not in blacklist

$email_check = app()->pdo->createCommand("SELECT COUNT(`id`) FROM `users` WHERE `email` = :email")->bindParams([
"email" => $email
])->queryScalar();
Expand Down
9 changes: 8 additions & 1 deletion framework/Validators/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,22 @@ public function setData($config)
foreach ($config as $name => $value) {
$this->$name = $value;
}
$this->buildDefaultValue();
}

public function setFileData($config) {
public function setFileData($config)
{
$this->_data += $config;
foreach ($config as $name => $value) {
$this->$name = UploadFile::newInstanceByName($name);
}
}

public function buildDefaultValue()
{

}

public function validate()
{
$this->_success = $this->_validator->validate($this->_data);
Expand Down

0 comments on commit d263c6c

Please sign in to comment.