I am trying to set hiddenField in the "create" view, where the field is set to the id of the current user. What do you get from springSecurityService.principal.id property.
I was wondering if it is possible to do this exclusively from the template, and not pass the value from the controller. eg.
<%@ page import="grails.plugins.springsecurity.SpringSecurityService" %> <% def springSecurityService %> <html> ... ... <g:hiddenField name="user.id" value="${springSecurityService.principal.id}"/> ...
I tried this code, but ended up getting a NullPointer exception with a reference to the "main" property.
Is there a way to do this, or do I need to explicitly pass the identifier of the current user in the system from the "create" method?
NOTE. Yes, I know that for any person, you can create a POST request with a protected hidden field. There are checks in the controller code to ensure that the current user can only create, edit, delete their own messages. My question is more related to the fact that you do not need to enter the code to transfer the current user in three different forms.
source share