Authorisation is a bit of a thorny issue. On the most part
authorisation in ClearPress is dealt with in a
view's authorised method. To authorise all read and
write actions for a view one could write:
Obviously this is way too simple for most applications. For many, the
level of authorisation needed is simply based on who the user is, if
they're logged in, or at most on which usergroup the user
is. $requestor usually holds the user object of the logged in
user, or a 'fake' public user, otherwise (faked for the simplicity of
making calls on a user object).
As the authorised method is invoked for every view it's
possible to implement default access restrictions in an
app::view superclass and then override the method in a derived
class and call up to SUPER::authorised where necessary.
From here, authorisation can become much more complex. For example if
a user is only authorised for a component in a complex page, the
authorisation for that component needs to be placed in the template
for the page like so: