0

I want to limit the fields that are permitted by my WebDataBinder so that ordinary users can't create objects attached to other accounts. I can do this pretty easily using an @InitBinder:

@InitBinder
void initBinder(WebDataBinder binder) {
    binder.disallowedFields = ['owner', 'createdAt']
}

However, I want administrators to be able to set the owner field.

The only "declarative" solution I've seen is to write duplicate controller methods that map based on the user's role and attach different binder specifications to the different fields. Is there any clean way to dynamically specify what fields are allowed/disallowed/required?

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152

0 Answers0