Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update
  • Loading branch information
bobimicroweber committed May 18, 2022
1 parent 4569719 commit 495f7fc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/MicroweberPackages/User/Models/User.php
Expand Up @@ -169,8 +169,8 @@ public function getValidatorMessages()
public function validateAndFill($data)
{
if (!empty($data['password']) && !empty($data['verify_password'])) {
$this->rules['password'] = 'required|min:1';
$this->rules['verify_password'] = 'required|same:password';
$this->rules['password'] = 'required|min:1|max:50';
$this->rules['verify_password'] = 'required|same:password|min:1|max:50';
}

$requireUsername = false;
Expand All @@ -182,6 +182,7 @@ public function validateAndFill($data)
$this->rules['username'] = [
'required',
'min:1',
'max:50',
Rule::unique('users', 'username')->ignore($data['id'], 'id')
];
}
Expand Down
9 changes: 5 additions & 4 deletions src/MicroweberPackages/User/UserManager.php
Expand Up @@ -738,18 +738,14 @@ public function save($params)
}
}
if ($force == false) {

if (!is_cli()) {
$validate_token = mw()->user_manager->csrf_validate($params);

if ($validate_token == false) {

return array(
'error' => _e('Confirm edit of profile', true),
'form_data_required' => 'token',
'form_data_module' => 'users/profile/confirm_edit'
);

}
}

Expand Down Expand Up @@ -832,9 +828,14 @@ public function save($params)
$data_to_save = $this->app->format->clean_xss($data_to_save);


if (isset($data_to_save['password2'])) {
$data_to_save['verify_password'] = $data_to_save['password2'];
}

$checkValidator = $user->validateAndFill($data_to_save);
$getValidatorMessages = $user->getValidatorMessages();


if ($checkValidator) {

if (isset($data_to_save['id'])) {
Expand Down
2 changes: 2 additions & 0 deletions src/MicroweberPackages/User/routes/api.php
Expand Up @@ -71,7 +71,9 @@
if(!is_logged()){
App::abort(403, 'Unauthorized action.');
}

$input = Input::all();

return save_user($input);
})->middleware(['api']);

Expand Down

0 comments on commit 495f7fc

Please sign in to comment.