[Zope] RE: Different Login Screens for Management and User?

Stefan Langerman lfalse@cs.rutgers.edu
Wed, 01 Mar 2000 00:26:18 -0500


I was working on the same kind of problem (see my earlier post today),
and I think
I found some solution, thanks to the many hints here and in the zope-ptk
list. It's
actually quite simple.

The trick is to play with exceptions. In your standard_html_header,
include something
like (replace 'Member' with the role you want):
<dtml-unless "AUTHENTICATED_USER.has_role('Member')">
   <dtml-raise type="Please Login!">
                <p>Please login before entering!<p>
   </dtml-raise>
</dtml-unless>

When the error is raised, the standard_error_message is called, so from
there,
you can do some more tests and go to the appropriate login page. I have
not
fully tested this yet, but I think it should work. I think if you put
type=Unauthorized in the dtml-raise tag, you should get the usual HTML
login instead of the error.

Anyone has a better (more elegant/original/creative) solution?

-- Stefan.

> James W. Howe jwh@allencreek.com wrote:
>
> In creating my web site, I'm planning on limiting access to certain
> portions of the site to registered users.  When a user attempts to "view"
> these areas, if they haven't logged in, I want to display a login page and
> get their name and password.  I also want to provide a way for the web site
> management team to login and perform management activities.  I would like
> to present a different login screen (maybe just a basic auth dialog) to
> allow access to management functions.  I've been playing around a little
> with GUF, but I haven't found a way to present two different login screens
> based on the type of page being accessed.  Is this type of functionality
> possible with Zope?  Would the LoginManager allow for this sort of thing?
>
> Thanks.
>
> James W. Howe                           mailto:jwh@allencreek.com
> Allen Creek Software, Inc.              pgpkey: http://ic.net/~jwh/pgpkey.html
> Ann Arbor, MI  48103
>