quarkiverse / quarkus-renarde

Server-side Web Framework with Qute templating, magic/easier controllers, auth, reverse-routing
Apache License 2.0
78 stars 19 forks source link

How to handle array/list of user roles in a single method on User? #102

Closed tmulle closed 1 year ago

tmulle commented 1 year ago

Hi,

I have a method on my User class which is a RenardeUser, etc.

I have a method called hasUserRole(String... roleNames) that I'd like to pass in a list of roles to check from my Qute templates in a single method call instead of multiple calls.

This works IF I pass in a list of roles like {#if inject:user && inject:user.hasUserRole("webadmin", "admin", "support")} but I get an exception during RUNTIME if I try to pass in a single value, ie. {#if inject:user && inject:user.hasUserRole("admin")}

The project compiles and starts up just fine but dies when I access the page with the single permission check.

Any ideas?

2023-02-26 17:27:11,348 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (executor-thread-1) Request failed: java.lang.ClassCastException: class java.lang.String cannot be cast to class [Ljava.lang.String; (java.lang.String and [Ljava.lang.String; are in module java.base of loader 'bootstrap')
FroMage commented 1 year ago

This appears to be a bug in Qute, no @mkouba ?

mkouba commented 1 year ago

Yes, looks like a bug in vargs processing. Pls file a new issue in https://github.com/quarkusio/quarkus/issues.

FroMage commented 1 year ago

Thanks!