Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a HasAllRoles convenience Loc

  • Loading branch information...
commit 4b2ad457951457f05de7c61708bcc53df179f611 1 parent 0272964
Timothy Perrett authored October 19, 2011
13  library/src/main/scala/shiro/snippet/snippets.scala
@@ -45,12 +45,17 @@ object LacksPermission extends SubjectSnippet {
45 45
 }
46 46
 
47 47
 object HasAnyRoles extends SubjectSnippet {
48  
-  def render(xhtml: NodeSeq): NodeSeq = {
49  
-    val delimiter = ","
  48
+  def render(xhtml: NodeSeq): NodeSeq = 
50 49
     serve(xhtml, attribute = "roles"){ roles => 
51  
-      hasAnyRoles(roles.split(delimiter))
  50
+      hasAnyRoles(roles.split(","))
  51
+    }
  52
+}
  53
+
  54
+object HasAllRoles extends SubjectSnippet {
  55
+  def render(xhtml: NodeSeq): NodeSeq = 
  56
+    serve(xhtml, attribute = "roles"){ roles => 
  57
+      hasAllRoles(roles.split(","))
52 58
     }
53  
-  }
54 59
 }
55 60
 
56 61
 object IsGuest extends SubjectSnippet {
3  library/src/main/scala/shiro/utils.scala
@@ -38,6 +38,9 @@ private[shiro] trait Utils {
38 38
   
39 39
   def hasAnyRoles(roles: Seq[String]) = 
40 40
     roles exists (r => hasRole(r.trim))
  41
+    
  42
+  def hasAllRoles(roles: Seq[String]) = 
  43
+    roles forall(r => hasRole(r.trim))
41 44
 }
42 45
 
43 46
 import net.liftweb.common.{Box,Failure,Full}

0 notes on commit 4b2ad45

Please sign in to comment.
Something went wrong with that request. Please try again.