Redirect after login...
Here's what I've been trying to figure out: When of my site's users authenticates, I'd like to immediately redirect them to their own home page in the system... In other words, upon becoming a member of the system, each user will have their own instance of a "member" class and upon authenticating, I want to forward them to the "View" view of their class. Now, I know that CMF does this (sort of) but I haven't found enough documentation on CMF so I'm trying to do this with regular old zclasses, etc. Any help would be greatly appreciated. Thanks, Rob
Looking at the source for the CMF login_form.dtml (the source is the best doc around...) we have: <!-- ****** Enable the automatic redirect ***** --> <dtml-if name="HTTP_REFERER"> <input type="hidden" name="came_from" value="<dtml-var name="HTTP_REFERER">"> </dtml-if> <!-- ****** Enable the automatic redirect ***** --> ...so that passes a hidden variable to the next form, logged_in.dtml: <!-- ****** Enable the automatic redirect ***** --> <dtml-if name="came_from"> <dtml-call expr="RESPONSE.redirect(came_from)"> </dtml-if> <!-- ****** Enable the automatic redirect ***** --> which redirects you automatically to where they were before. It's easy enough to change the latter to get the member's homepage (look for what the 'my stuff' link in the actions box does), or to whatever custom stuff you're dealing with (getting the user info from the acl_user or whatever). P.S. if you're using CMF, you might want to post this stuff on zope-cmf@zope.org list. Marc
From: Rob Foster <rob@thefosters.com> Date: Sat, 3 Nov 2001 12:48:36 -0700 To: zope@zope.org Subject: [Zope] Redirect after login...
Here's what I've been trying to figure out:
When of my site's users authenticates, I'd like to immediately redirect them to their own home page in the system... In other words, upon becoming a member of the system, each user will have their own instance of a "member" class and upon authenticating, I want to forward them to the "View" view of their class.
Now, I know that CMF does this (sort of) but I haven't found enough documentation on CMF so I'm trying to do this with regular old zclasses, etc.
Any help would be greatly appreciated.
Thanks, Rob
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Thanks for the reply, but I probably didn't explain very well that I'm NOT using CMF. I haven't found enough documentation on it to help me. I'm trying to do this with the standard Zope installation. Any other ideas would be great. On Saturday, November 3, 2001, at 01:26 PM, marc lindahl wrote:
Looking at the source for the CMF login_form.dtml (the source is the best doc around...) we have:
<!-- ****** Enable the automatic redirect ***** --> <dtml-if name="HTTP_REFERER"> <input type="hidden" name="came_from" value="<dtml-var name="HTTP_REFERER">"> </dtml-if> <!-- ****** Enable the automatic redirect ***** -->
...so that passes a hidden variable to the next form, logged_in.dtml:
<!-- ****** Enable the automatic redirect ***** --> <dtml-if name="came_from"> <dtml-call expr="RESPONSE.redirect(came_from)"> </dtml-if> <!-- ****** Enable the automatic redirect ***** -->
which redirects you automatically to where they were before. It's easy enough to change the latter to get the member's homepage (look for what the 'my stuff' link in the actions box does), or to whatever custom stuff you're dealing with (getting the user info from the acl_user or whatever).
P.S. if you're using CMF, you might want to post this stuff on zope-cmf@zope.org list.
Marc
From: Rob Foster <rob@thefosters.com> Date: Sat, 3 Nov 2001 12:48:36 -0700 To: zope@zope.org Subject: [Zope] Redirect after login...
Here's what I've been trying to figure out:
When of my site's users authenticates, I'd like to immediately redirect them to their own home page in the system... In other words, upon becoming a member of the system, each user will have their own instance of a "member" class and upon authenticating, I want to forward them to the "View" view of their class.
Now, I know that CMF does this (sort of) but I haven't found enough documentation on CMF so I'm trying to do this with regular old zclasses, etc.
Any help would be greatly appreciated.
Thanks, Rob
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Well, the same thing can apply, just modify the regular login forms.
From: Rob Foster <rob@thefosters.com> Date: Sat, 3 Nov 2001 13:36:17 -0700 To: marc lindahl <marc@bowery.com> Cc: zope@zope.org Subject: Re: [Zope] Redirect after login...
Thanks for the reply, but I probably didn't explain very well that I'm NOT using CMF. I haven't found enough documentation on it to help me. I'm trying to do this with the standard Zope installation.
Any other ideas would be great.
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
Rob Foster writes:
When of my site's users authenticates, I'd like to immediately redirect them to their own home page in the system... In other words, upon becoming a member of the system, each user will have their own instance of a "member" class and upon authenticating, I want to forward them to the "View" view of their class. Are you sure, you want that?
I would be very angry, when that would happen, because it would make bookmarks to my private pages less effective. Usually, the authentication (login) request comes up when I access a protected page. When I log in, I want to see *THIS* page and not my home page... But follow up messages indicate, that you do not mean "authenticate" but "register" (i.e. "become a new user"). In this case: You cannot do it with HTTP basic authentication, you need a form of cookie authentication. The reason: HTTP authentication is not controlled by the server; its a client service, it wants to pop up its login dialog to get the user credentials. When you are ready to use cookie based authentication, then you need to tell the User Folder to set the cookies for the newly created user (or do it yourself). How this works depends on the User Folder you are using. You can search the mailing list archives: I once helped someone to do this with CookieCrumbler (but do not know out of hand how it goes...). Dieter
Hello!
When of my site's users authenticates, I'd like to immediately redirect them to their own home page in the system... In other words, upon becoming a member of the system, each user will have their own instance of a "member" class and upon authenticating, I want to forward them to the "View" view of their class.
Are you sure, you want that?
I would be very angry, when that would happen, because it would make bookmarks to my private pages less effective.
Usually, the authentication (login) request comes up when I access a protected page. When I log in, I want to see *THIS* page and not my home page...
I think that the scenario Rob is talking about is a rather common one. We have done several intranet or extranet systems with exactly these requirements. People want to have one single login link on the public part of the page that redirects users to the area they belong to after logging in. This doesn't have to do anything with getting registered by the way. It also doesn't interfere with bookmarking (or linking) pages within the private part of the site, because if such a private page is accessed directly, it will of course trigger a normal login. In case of BASIC AUTHENTICATION, this will not cause any redirection anyway. If you use Cookie Crumbler, you have the option of redirecting back to the URL you are comming from, but it might be a bit complicated to configure ... To answer Rob's second question: As Dieter Maurer points out, you can indeed NOT use auto-login after successful registration in combination with plain BASIC AUTHENTICATION, because you can not control the browser's way of asking users for their credentials. With cookies, this is perfectly possible ... Cheers Joachim
participants (4)
-
Dieter Maurer -
Joachim Werner -
marc lindahl -
Rob Foster