Skip to content

Commit

Permalink
Refactoring Access Restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf Muri committed Jun 15, 2010
1 parent e60dc84 commit 8bee1f6
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions web/src/main/scala/bootstrap/liftweb/Boot.scala
Expand Up @@ -49,7 +49,7 @@ class Boot {
case (Full(Req("tour" :: "view" :: Nil, _, //google maps
GetRequest)), _) =>
"text/html; charset=utf-8"
case (Full(Req("tour" :: "stage" :: "view" :: Nil, _, //google maps
case (Full(Req("tour" :: "stage" :: "view" :: Nil, _, //google maps
GetRequest)), _) =>
"text/html; charset=utf-8"
case (_, Full(accept))
Expand Down Expand Up @@ -79,19 +79,28 @@ class Boot {
LiftRules.dispatch.append(GridAPI)
LiftRules.dispatch.append(ImageLogic.matcher)

def conditionalAccess(cond: List[Boolean]) = If(
() => cond.exists(_ == true),
() => RedirectWithState("/accessrestricted", RedirectState(() => S.error(S.?("member.operation.denied"))))
)

// Build SiteMap (used for navigation, access control...)
val LoggedIn = If(
() => UserManagement.loggedIn_?,
() => RedirectWithState(UserManagement.loginPageURL, RedirectState(() => S.error(S.??("must.be.logged.in")))))

val EntryModification = If(
() => {
(UserManagement.currentUser == blogEntryVar.is.owner) ||
(blogEntryVar.is.owner == null) ||
(UserManagement.currentUser.roles.exists(_ == "mod"))
},
() => RedirectWithState("/accessrestricted", RedirectState(() => S.error(S.?("member.operation.denied")))))
// val EntryModification = If(
// () => {
// (UserManagement.currentUser == blogEntryVar.is.owner) ||
// (blogEntryVar.is.owner == null) ||
// (UserManagement.currentUser.roles.exists(_ == "mod"))
// },
// () => RedirectWithState("/accessrestricted", RedirectState(() => S.error(S.?("member.operation.denied")))))
val EntryModification = conditionalAccess(List(
UserManagement.currentUser == blogEntryVar.is.owner,
blogEntryVar.is.owner == null,
UserManagement.currentUser.roles.exists(_ == "mod"))
)

val PictureModification = If(
() => {
Expand Down

0 comments on commit 8bee1f6

Please sign in to comment.