Skip to content

W0403: A control hidden by a permission its event doesn't check ​

The markup shows a control only under perms.Has("x"), and the event it sends runs a method that checks no permission x. Hiding the control changes what the visitor sees; anyone can still send the event, so the method must check: @auth.Requires("x") (or @auth.RequiresAny) on it, or perms.Has("x") in its body, returning web.Forbidden when it is false; a pattern such as orders.* covers what it matches. auth.Can counts too, though a vuka file reads perms (W0402). Reported by vuka vet.

Wrong ​

html
<script lang="go">
func (p *Placements) Approve(ctx context.Context) error { … }
</script>

if perms.Has("placements.approve") {
  <button onClick={Approve}>Approve</button>
}
html
<script lang="go">
@auth.Requires("placements.approve")
func (p *Placements) Approve(ctx context.Context) error { … }
</script>

if perms.Has("placements.approve") {
  <button onClick={Approve}>Approve</button>
}

Or, in the method:

go
func (p *Placements) Approve(ctx context.Context) error {
	if !perms.Has("placements.approve") {
		return web.Forbidden
	}
	…
}

See permissions in templates.

Released under the MIT License. Vuka builds on Go and its tools, which are made by the Go Authors. Vuka is not affiliated with Google or the Go project. Go is a trademark of Google LLC.