Hi Edgar,

I may be misunderstanding how actions work, but at least for how we've used
them in our project, anything after an action always executes, regardless of
whether the action returns a null Map or not.  If an action returns a null
Map, it skips the steps inside the act tag, but it will continue executing
the steps after the act tag.  If this isn't always the case, please let me
know.  I'll be the first to admit that my understanding of Cocoon is far
from perfect!  =)

Harry


-----Original Message-----
From: Graaf, Edgar de (fin) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 23, 2002 10:25 AM
To: '[EMAIL PROTECTED]'
Subject: RE: how do I redirect in an Action?


Harry,

I have to look in to you example later. 
But the last redirect is to a page that ask you to try again... when the
action doesn't fail(the password is right) that redirect is not executed
(that between the <map:act> is).

-----Oorspronkelijk bericht-----
Van: Lai, Harry [mailto:[EMAIL PROTECTED]]
Verzonden: donderdag 23 mei 2002 17:19
Aan: '[EMAIL PROTECTED]'
Onderwerp: RE: how do I redirect in an Action?


Hi Christopher and Edgar,

Couple things.  I could be wrong, but I believe in Edgar's example, the
redirect would always execute (since it sits outside the action).

Also, depending on how many protected url matchers you have, you can also
delegate all work to a resource where you could put all your authentication
and redirect logic (so you don't have to have it in each matcher).  So you
could do something like this:

        <map:match pattern="some protected url">
                <map:call resource="authenticatedAccess">
                        <map:parameter name="someIDForThisPipe"
value="foo"/>
                        ... any other params you might need to process this
pipe ...
                </map:call>
        </map:match>

        <map:match pattern="some other protected url">
                <map:call resource="authenticatedAccess">
                        <map:parameter name="someIDForThisPipe"
value="bar"/>
                        ... any other params you might need to process this
pipe ...
                </map:call>
        </map:match>

And the resource might look like:

        <map:resource name="authenticatedAccess">
                <map:act type="my-authenticator">
                        <map:select type="parameter">
                                <map:parameter
name="parameter-selector-test" value="{authStatus}"/>
                                <map:when test="success">
                                        ... stuff to process pipeline based
on params
                                </map:when>
                                <map:otherwise>
                                        <map:redirect-to
uri="loginpage.html"/>
                                </map:otherwise>
                        </map:select>
                </map:act>
        </map:resource>


Anyway, hope that helps!

Harry

-----Original Message-----
From: Graaf, Edgar de (fin) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 23, 2002 10:01 AM
To: '[EMAIL PROTECTED]'
Subject: RE: how do I redirect in an Action?


Christopher,

<map:act...> can't contain matchers, how else would cocoon know that the
action should be run?

try:

      <map:match pattern="some protected url">
        <map:act type="my-authenticator">
            ...
        </map:act>
        <map:redirect-to uri="loginpage.html"/>
      </map:match>

      <map:match pattern="some other protected url">
        <map:act type="my-authenticator">
            ...
        </map:act>
        <map:redirect-to uri="loginpage.html"/>
      </map:match>

regards

Edgar

-----Oorspronkelijk bericht-----
Van: Christopher Painter-Wakefield [mailto:[EMAIL PROTECTED]]
Verzonden: donderdag 23 mei 2002 15:52
Aan: [EMAIL PROTECTED]
Onderwerp: Re: how do I redirect in an Action?



I'm trying to implement a homegrown authentication scheme.  One of our
types of users will be "authenticated" by coming into the system with
appropriate credentials as request parameters in the URL (we will e-mail
them their unique URL).  This is to avoid generating a large number of user
ids and requiring all these users to remember credentials for a system they
will likely use once or twice a year.  None of the existing server-level
authentication schemes would seem to support this.

Once the user has "logged in" by providing the correct credentials, I
planned to store their identity and the fact that they have been
authenticated in their session.

So, each time a request is made to a protected page, I need to first check
the session to see if the user is already authenticated.  If not, I need to
check the request parameters, if available, against the database.  If both
of these fail, I need to redirect the user to a polite login failure page
(at some point we will have users that use a traditional login mechanism,
at which point we'll probably redirect to a login form).

I read the Action docs and searched through the mail archives, and I
thought I could do something like this:

<map:act type="my-authenticator">
      <map:match pattern="some protected url">
            ...
      </map:match>

      <map:match pattern="some other protected url">
            ...
      </map:match>
</map:act>

As I understood it, if the authentication fails, I would redirect to my
failure page in the Action and return null to prevent anything inside the
<map:act> element from running.  If the authentication succeeds, I return
an empty Map and the stuff inside the <map:act> element will run as usual.
Now that I'm saying all that it doesn't sound very likely, but I swear I
got it all from the docs.

Any suggestions?

-Christopher



From: "Christopher Painter-Wakefield" <[EMAIL PROTECTED]>

> What is the proper way to redirect in an Action?

Why do you have to redirect in an action?
I would not suggest it.

Redirect instead in the sitemap based on the results of the Action.

--
Nicola Ken Barozzi                   [EMAIL PROTECTED]
            - verba volant, scripta manent -
   (discussions get forgotten, just code remains)
---------------------------------------------------------------------




---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to