Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to attemp sec:loggedInUserInfo into a variable in gsp

Tags:

grails

gsp

I want to get value of sec:loggedInUserInfo and attempt into a variable named user.

My code looks like this:

<sec:loggedInUserInfo field="username" /> 

<%
  def user = *value of field loggedInUserInfo *
%>

Is it possible for doing that?

like image 870
Mr Zoomzoom Avatar asked May 26 '11 03:05

Mr Zoomzoom


2 Answers

This is simpler and works fine for me:

<g:set var="user" value="${sec.username()}" />
like image 154
Chris Avatar answered Oct 09 '22 14:10

Chris


To assign any field of the UserDetails instance referred to by <sec:loggedInUserInfo> to a variable you can use:

<g:set var="fullName" value="${sec.loggedInUserInfo(field:'fullName')}" />

(see also Custom User Details)

like image 21
martin Avatar answered Oct 09 '22 14:10

martin