Skip to content

Taglib does not work in main layout #14099

@mobilemindtec

Description

@mobilemindtec

Hi,

I'm upgrading a project to version 7.0.0-M3 and I noticed that a taglib that is called in the main layout doesn't work correctly. For example:

class AuthService {

	def springSecurityService // injected by Spring	

	def getCurrRoles() {
		def auth = springSecurityService.authentication 
		def roles = auth?.authorities?.collect { it.authority }	 ?: []
		log.info "roles = $roles"
		roles
	}		

	def getUser(){
	    def principal = springSecurityService.getPrincipal()
	    if(!principal || "anonymousUser".equals(principal.toString())){
	      return null         
	    }
	    User.findWhere(username: springSecurityService.getPrincipal().username) 
	}	
}

class AuthTagLib {

	static namespace =  "auth"
	def authService

	def roles = { attrs, body -> 
		out << authService.currRoles
	}	

	def user = { attrs, body -> 
		out << authService.user
	}	
}

When I call (logged in) <auth:roles /> <auth:user /> from any page the values ​​return correctly, but when I call it from main.gsp it returns a empty list and null respectively. In version 6 the taglib responded correctly. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions