Fix wrong tagnames in exceptions.
diff --git a/grails-app/taglib/JsecTagLib.groovy b/grails-app/taglib/JsecTagLib.groovy
--- a/grails-app/taglib/JsecTagLib.groovy
+++ b/grails-app/taglib/JsecTagLib.groovy
@@ -130,7 +130,7 @@
*/
def hasRole = { attrs, body ->
// Does the user have the required role?
- if (checkRole(attrs)) {
+ if (checkRole(attrs, 'hasRole')) {
// Output the body text.
out << body()
}
@@ -142,7 +142,7 @@
*/
def lacksRole = { attrs, body ->
// Does the user have the required role?
- if (!checkRole(attrs)) {
+ if (!checkRole(attrs, 'lacksRole')) {
// Output the body text.
out << body()
}
@@ -213,7 +213,7 @@
* has the given permission.
*/
def hasPermission = { attrs, body ->
- if (checkPermission(attrs)) {
+ if (checkPermission(attrs, 'hasPermission')) {
// Output the body text.
out << body()
}
@@ -224,7 +224,7 @@
* does not have the given permission.
*/
def lacksPermission = { attrs, body ->
- if (!checkPermission(attrs)) {
+ if (!checkPermission(attrs, 'lacksPermission')) {
// Output the body text.
out << body()
}
@@ -245,7 +245,7 @@
* given tag attributes. Returns true if the user
* has the role, otherwise false.
*/
- private boolean checkRole(attrs) {
+ private boolean checkRole(attrs, tagname) {
// Extract the name of the role from the attributes.
def roleName = attrs['name']
def inList = attrs['in']
@@ -259,7 +259,7 @@
return results.any()
}
else {
- throwTagError('Tag [hasRole] must have one of [name] or [in] attributes.')
+ throwTagError('Tag [${tagname}] must have one of [name] or [in] attributes.')
}
}
@@ -268,7 +268,7 @@
* the given tag attributes. Returns true if the user
* has the permission, otherwise false.
*/
- private boolean checkPermission(attrs) {
+ private boolean checkPermission(attrs, tagname) {
def permission
def permClass = attrs['type']
if (!permClass) {
@@ -277,7 +277,7 @@
permission = attrs['permission']
if (!permission) {
- throwTagError('Tag [hasPermission] must have either a [type] attribute or a [permission] one.')
+ throwTagError("Tag [${tagname}] must have either a [type] attribute or a [permission] one.")
}
if (!(permission instanceof org.jsecurity.authz.Permission)) {
@@ -289,7 +289,7 @@
// 'target' defaults to '*'.
def actions = attrs['actions']
if (!actions) {
- throwTagError('Tag [hasPermission] must have an [actions] attribute if [type] is used.')
+ throwTagError('Tag [${tagname}] must have an [actions] attribute if [type] is used.')
}
def target = attrs['target']
@@ -302,7 +302,7 @@
permission = constructor.newInstance([ target, actions ] as Object[])
}
catch (ClassNotFoundException ex) {
- throwTagError("Cannot find class [${permClass}] from attribute [hasPermission].")
+ throwTagError("Cannot find class [${permClass}] from attribute [permission] in tag [${tagname}].")
}
}