[Zope] Redirect after login...

Joachim Werner joe@iuveno-net.de
Sat, 3 Nov 2001 23:47:00 +0100


> Well, the same thing can apply, just modify the regular login forms.

Rob, the key to your problem is the   <dtml-call
expr="RESPONSE.redirect(came_from)">
part of Marc's example. If you know how to build the path to the user's home
directory from his user name, you can do things like:

<dtml-call
"RESPONSE.redirect('http://yourserver.com/Members'+AUTHENTICATED_USER.getId(
))">

to redirect them to a folder that is in "Members" and uses their user ID as
name.

The redirect has to be put into the document the users will see right after
login (or better WOULD see, as they will be redirected). E.g. for "normal"
BASIC AUTHENTICATION (without cookie crumbler or so), just create a DTML
Method "login" with the redirect line in it.

You can also do the same with a Script(Python) of course. Then the syntax
would be:

context.REQUEST.RESPONSE.redirect('http://yourserver.com/Members'+context.RE
QUEST.AUTHENTICATED_USER.getId())">


Then protect that login method with some security restrictions so that any
anonymous user who wants to visit it will get a login prompt. With the
newest Zope versions, the easiest way to do this would be restricting "View"
to "Authenticated" users.

Then put a link to your login method somewhere on your site's homepage. If
users click on it, they will get the login prompt and will be redirected to
their home folders.

If you use cookie crumbler, the procedure is similar, but you put the
redirect into the method that is called by the login form. If you need an
example for that, feel free to ask again. It is just a bit lengthy for this
post ...


Cheers

Joachim