2013-02-14 2 views
0

저는 스프링 보안을 사용하고 있습니다. 사용자 컨트롤러의 도메인 객체를 가져와야합니다.Grails는 내 도메인에 액세스합니다. @Secured의 사용자 ([...])

@Secured(['principal...'])을 호출하면 org.codehaus.groovy.grails.plugins.springsecurity.GrailsUser 유형의 개체가 반환됩니다.

grails.plugins.springsecurity.userLookup.userDomainClassName = 'project.auth.User' 

내가 어떻게 할 수있는 그러나, 내가 무엇을 찾고있어 내 Config.groovy과 같이 정의 한 사용자 도메인 객체는?

+0

내가 @Secured() 내가 아는 주석 – user2022371

답변

0

springSecurityService를 사용하여 현재 사용자를 확보 할 수없는 이유는 무엇입니까? 컨트롤러에서 springSecurityService에 액세스 할 수 있습니다. 이것은 사용자 객체를 반환합니다.

@Secured[... 
class MyClassController { 

    def springSecurityService 

    def myMethod() { 
     User user = springSecurityService.getCurrentUser() 
    } 
} 

그것은 this 문서에 설명 된 것

+0

에 springSecurityService.currentUser에 접근 할 수 있다면 충분히 것,하지만 난 @Secured의 말뭉치 주석에서이 서비스를 필요로 할 수 있기 때문에 User 클래스의 메서드에 따라이 액션에 액세스 할 수 있습니다. 예를 들어 : 클래스 사용자 선호도 { \t 과도 springSecurityService \t 문자열 이름 \t 문자열 암호 \t 부울 활성화 \t ... \t \t 정적 hasMany의 \t \t = [mensajesRecibidos : Mensaje]을 \t} \t // – user2022371

+0

나도 알아,하지만이 서비스는 @Secured anotation에 액세스해야하는데, User 클래스의 메서드에 따라이 액션에 액세스 할 수 있기 때문이다. 예를 들어 : 클래스 사용자 선호도 { \t 정적 hasMany의 \t = [mensajesRecibidos : Mensaje] } 및 MensajeController에 show 액션 당신이 보여줄 수있는 Mensaje 경우에 액세스 할 수 있습니다 나는이 클래스 같은 것을 의미, 당신입니다 MensajeController { @Secured ([ 'currentUser.mensajesRecibidos.contains (Mensaje.get (request.params.id))']) def show() { – user2022371