On Tue, Aug 18, 2009 at 6:10 PM, Keith K <quasike...@gmail.com> wrote:
> > I'd like to test the User for different access levels with functions > for each menu item, looking at the User.scala mapped object. Is there > some example code out there that does more than check for logged-in > status? Can you create a method that returns a Boolean to indicate if a page is allowed to be accessed? If so, you've got everything you need... def canViewSecretPage_? : Boolean = // your logic here Loc("my secret page", List("secret" :: Nil), "Secret page", If(canViewSecretyPage_? _, "Sorry dude, you can't go there")) Does this help? > > > -Ketih > > On Jul 16, 5:43 am, Chris Lewis <burningodzi...@gmail.com> wrote: > > I did use an archetype, but it was a 1.0 and must have been the > > bare-bones (there were no models generated). > > > > David Pollak wrote: > > > > > On Wed, Jul 15, 2009 at 3:17 AM, Chris Lewis <burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>> wrote: > > > > > I didn't, but I'd been looking through liftweb/sites for examples > to no > > > avail. This one has helped out a good deal - now I know about the > built > > > in User.sitemenu. The only issue now is that the pages under > /user_mgt > > > aren't getting rendered in a layout template - ie, just partial > content. > > > And because they're XML docs, FF is rendering XML. I'm only > assuming > > > those templates surround their content at "content" (as they do in > the > > > 1_1 example). I don't think this is a 1.0 issue, but it's possible. > > > > > In the User singleton, add the following line: > > > > > override def screenWrap = Full(<lift:surround with="default" > at="content"> > > > <lift:bind /></lift:surround>) > > > > > All of this stuff is done for you when you use the Maven archetype to > > > create a new project. > > > > > thanks > > > chris > > > > > David Pollak wrote: > > > > > > On Tue, Jul 14, 2009 at 3:32 PM, Chris Lewis > > > <burningodzi...@gmail.com <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>>> wrote: > > > > > > I guess the first question I should have asked is how do I > go > > > about > > > > logging a user in. I have my user model, which now mixes in > > > > MegaProtoUser. I also persist instances, but I don't know > how > > > to "start" > > > > a user session. I noticed the logUserIn method - I assume > > > that's where > > > > to start when I get back into the app later this evening, > but > > > I was > > > > wondering if there are any example apps that use this? I > > > didnt see any > > > > in the current source, and, assuming it makes a difference, > I'm > > > > using 1.0. > > > > > > thanks again, > > > > chris > > > > > > Chris, > > > > > > Did you start your app based on one of the Lift templates? > > > > > > If you take a look at line 27 of: > > > > > > http://github.com/dpp/lift_1_1_sample/blob/master/src/main/scala/boot... > > > > > > You'll see how the MegaProtoUser can manage its own menus. From > > > that, > > > > you get login, logout, etc. > > > > > > Does this help? > > > > > > Thanks, > > > > > > David > > > > > > David Pollak wrote: > > > > > > > On Tue, Jul 14, 2009 at 9:20 AM, glenn <gl...@exmbly.com > > > <mailto:gl...@exmbly.com> > > > > <mailto:gl...@exmbly.com <mailto:gl...@exmbly.com>> > > > > > <mailto:gl...@exmbly.com <mailto:gl...@exmbly.com> > > > <mailto:gl...@exmbly.com <mailto:gl...@exmbly.com>>>> wrote: > > > > > > > I do something similar in menu items to hide them for > > > > different user > > > > > roles, but > > > > > the error message: No Navigation Defined, is > displayed > > > if the > > > > right > > > > > user isn't logged in. > > > > > How do I turn this off? > > > > > > > Upgrade based on the fix I just checked in. :-) > > > > > > > On Jul 14, 4:02 am, Chris Lewis > > > <burningodzi...@gmail.com <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>> > > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>>>> wrote: > > > > > > Too easy! Thanks for the help David - I'll msg the > > > channel > > > > when > > > > > the app > > > > > > is on github. Fine job with Lift - it's been a joy > > > so far! > > > > > > > > David Pollak wrote: > > > > > > > > > On Mon, Jul 13, 2009 at 8:57 PM, Chris Lewis > > > > > <burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>>> > > > > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>> > > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>>>>> wrote: > > > > > > > > > That'll get me started. User there however, > > > must mixin > > > > > MegaProtoUser > > > > > > > instead of ProtoUser right (getting > > > compilation errors)? > > > > > > > > > Yeah... you have to build your User from > > > > > MegaProtoUser/MetaMegaProtoUser. > > > > > > > > > I guess I'm interested in how/when/where the > > > checking > > > > > happens, but that > > > > > > > suggests I need to have a source dive. I do > > > need secured > > > > > pages in the > > > > > > > SiteMenu (which I can have once I work out > the > > > > compilation > > > > > issues), but > > > > > > > what if I need to secure a URL handled via > custom > > > > dispatch, > > > > > and so is > > > > > > > not in the menu? > > > > > > > > > Sitemap is for protecting XHTML pages... stuff > that's > > > > rendered > > > > > to the > > > > > > > browser. > > > > > > > > > If you have a custom dispatch, then you have to > > > build the > > > > > protection > > > > > > > logic into the dispatch: > > > > > > > > > case Req("my_page" :: "thing" :: Nil, _, > > > GetRequest) if > > > > > User.loggedIn_? > > > > > > > => () => XmlResponse(<hello>world</hello>) > > > > > > > > > A little bonus of the app is a bookmarklet > that > > > > > > > actually makes it useful, and it hits up > that > > > URL. > > > > The idea > > > > > would be to > > > > > > > secure that URL in lift and if the user is > > > logged it > > > > would > > > > > just work. > > > > > > > > > I'll hack on it a bit more tomorrow - thanks > > > again! > > > > > > > > > chris > > > > > > > > > David Pollak wrote: > > > > > > > > In Boot.scala, define your SiteMap as: > > > > > > > > > > // Build SiteMap > > > > > > > > val entries = Menu(Loc("Home", > > > List("index"), > > > > > "Home")) :: > > > > > > > > Menu(Loc("Protected", > List("protected"), > > > > "Protected", > > > > > > > > If(User.loggedIn_? _, "You must be loggd > in to > > > > view this > > > > > page"))) :: > > > > > > > > User.sitemap > > > > > > > > > > Note the "If()" clause that tests if the > > > user is > > > > logged > > > > > in and > > > > > > > will not > > > > > > > > display the menu item or let you access > > > that page. > > > > > > > > > > Is this what you're looking for? > > > > > > > > > > On Mon, Jul 13, 2009 at 8:23 PM, Chris > Lewis > > > > > > > <burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>> <mailto: > burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>>> > > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>> <mailto: > burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>>>> > > > > > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>> > > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>>> > > > > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>> > > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com> > > > > <mailto:burningodzi...@gmail.com > > > <mailto:burningodzi...@gmail.com>>>>>> wrote: > > > > > > > > > > Hello list, > > > > > > > > > > I'm writing a lift > > > > ... > > > > read more ยป > > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---