Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

表单Filed的readonly,disable和display字段的值仍然可以修改 #310

Closed
acshiryu opened this issue Jul 11, 2020 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@acshiryu
Copy link

  • Laravel Version: 7
  • PHP Version: 7.4
  • Dcat Admin Version: 1.5.2

Description:

经测试,直接使用浏览器的审查元素,删除掉disable或者readonly属性,然后提交,该字段的值竟然保存成功了。已经测试可以直接通过这个方法修改用户的用户名,这在某些需要严格权限认证的地方不够严谨,建议给Form的removeIgnoredFields方法加上对这些字段的筛查

    public function removeIgnoredFields($input)
    {
        Arr::forget($input, $this->ignored);

        /** @var Field $field */
        foreach ($this->builder->fields() as $field){
            if ($field instanceof Field\Display || $field->hasAttribute('disabled') || $field->hasAttribute('readonly')){
                Arr::forget($input, $field->column());
            }
        }

        return $input;
    }

Steps To Reproduce:

@jqhph
Copy link
Owner

jqhph commented Jul 11, 2020

这个是浏览器的特性,你可以自己处理,display是不能保存的因为display就只是个div而已。

@acshiryu
Copy link
Author

acshiryu commented Jul 11, 2020

display虽然是div,但可以审查元素修改为text提交,然后后端是依旧接受这个字段并允许修改了
我将个人设置的name标签复制一下,改成username 可以提交修改用户名
image
image

@jqhph jqhph added the enhancement New feature or request label Jul 11, 2020
@jqhph
Copy link
Owner

jqhph commented Jul 11, 2020

感谢建议,已支持这个功能

@jqhph jqhph closed this as completed Jul 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants