(Quick Reference)

userHasAnyRole(roleList)

Available in Controllers, Domains, Taglibs and Services

This method returns true if the current user has any of the roles listed.

The implementation of this method is provided by the security provider you have installed.

Usage

class PurchaseService {
    void updatePurchase(Purchase p) {
        if (userHasAnyRole(['ROLE_USER', 'ROLE_ADMIN'])) {
            …
        }
    }
    …
}

Arguments

NameDescription
roleListThe list of roles to test for