Exception evaluating SpringEL expression: "#authorization.expression('isAuthenticated()')" (overview)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Exception evaluating SpringEL expression: "#authorization.expression('isAuthenticated()')" (overview)

Fearghal
Hi,

I am trying to use Thymeleaf with Spring Boot/MVC/Security but I can't get it to check if a user is authenticated.

I'm trying to configure some javascript components depending on the current user. For example, I want "editable" to be set to false for unauthenticated users.

This is what I have tried:

<script th:inline="javascript"> ... editable: /*[[${#authorization.expression('isAuthenticated()')}]]*/ false, ..... </script>
But I am getting back an error "Exception evaluating SpringEL expression: "#authorization.expression('isAuthenticated()')" (overview)".

Can anyone explain what I need to do to get this working?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Exception evaluating SpringEL expression: "#authorization.expression('isAuthenticated()')" (overview)

Zemi
Administrator
Hello,

have you tried that expression outside the Javascript block to see it the problem is related to the expression or not?

You could also try a simple expression, like
   #authentication.isAuthenticated()

Regards,
  Zemi