On 1 Mar 2011, at 14:57, Carl Youngblood wrote:
> Never mind, I think I got enough ideas from looking at Aslak
> Hellesøy's ba extension.
>
> On Tue, Mar 1, 2011 at 1:49 PM, Carl Youngblood <[email protected]> wrote:
>> I found this topic on the mailing list from a few years ago. I'm
>> building an extension that supports site user registration and login.
>> I would like to be able to support two ways of restricting access to
>> page content. I would like to create a different page type that would
>> require login to be seen, such as:
>>
>> class SecurePage < Page
>> end
>>
>> and I'd like to create tags for displaying content only if a user is
>> logged in and only if a user is not logged in, such as:
>>
>> <r:if_authenticated>Secret information</r:if_authenticated>
>> <r:unless_authenticated>Public information</r:unless_authenticated>
You can do nearly all of this with the reader and reader_group extensions, if
you don't mind adopting quite a lot of framework machinery to achieve a fairly
simple purpose. Reader defines the tags that you mention and reader_group lets
you restrict any page to one or more groups.
If controlling access is going to be your only requirement then I wouldn't
bother with all that: the key methods are find_page and show_page in
SiteController and, as others have said, Page.cache?. You may find a starting
point here:
https://github.com/spanner/radiant-reader_group-extension/blob/master/lib/site_controller_extensions.rb
The main difficulty will be that you want the same page to appear differently
to a logged-in user. That's going to make effective caching much harder, though
with care you can probably cache the default page and bypass the cache when a
login cookie is present.
best,
will