cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zamek <za...@vili.pmmf.hu>
Subject Re: getting username from session after authentication
Date Fri, 27 Feb 2004 12:00:49 GMT
Hi All,

On Thursday 26 February 2004 10.34, Laurent Trillaud wrote:
> Zoltan
> I guess that the authenticate action is missing. The authentication
> context isn't loaded
> Try this stuff
> <map:match pattern="*.html">
>   <map:act type="auth-protect">
>     blah blah
>     <map:parameter name="username" value="{name}"/>
>     blah blah
>   </map:act>
> </map:match>
>
> {name} or {user/name} that depend what you have done in the handler
> authentication uri.

Thanks for response, but I am a beginner in Cocoon and I don´t understand 
it, or it doesn´t works for me. :-(
My goal is make different menus depending to valid users or anonymous user.
I would like to make it my xsl if it possible.

I made a short test, please check and modify it:
my sitemap.xmap:
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">

  <map:pipelines>
    <map:component-configurations>
      <authentication-manager>
        <handlers>
          <handler name="demohandler">
            <redirect-to uri="cocoon:/login"/>
            <authentication uri="cocoon:raw:/authenticate"/>
          </handler>
        </handlers>
      </authentication-manager>
    </map:component-configurations>

    <map:pipeline caching="off">
      
      <map:match pattern="">
        <map:redirect-to uri="index.html"/>
      </map:match>

      <map:match pattern="index.html">
        <map:generate src="index.xml"/>
        <map:transform src="stylesheets/simple-page2html.xsl"/>
        <map:transform type="encodeURL"/>
        <map:serialize/>
      </map:match>
      
      <map:match pattern="login">
        <map:act type="auth-loggedIn">
          <map:parameter name="handler" value="demohandler"/> 
          <map:redirect-to uri="index.html"/>
        </map:act> 
        <map:generate src="public/login.xml"/>
	<map:transform type="session"/>
        <map:transform src="stylesheets/simple-page2html.xsl">
	  <map:parameter name="use-request-parameter" value="true"/>
	</map:transform>
        <map:transform type="encodeURL"/>
        <map:serialize/>
      </map:match>

      <map:match pattern="do-login">
        <map:act type="auth-login">
          <map:parameter name="handler" value="demohandler"/>
          <map:parameter name="parameter_name" 
value="{request-param:username}"/>
          <map:redirect-to uri=""/>
        </map:act>
        <map:redirect-to uri="login"/>
      </map:match>

      <map:match pattern="protected-*">
        <map:act type="auth-protect">
          <map:parameter name="handler" value="demohandler"/> 	    
	  <map:parameter name="username" value="{username}"/> <------------------ 
here is your stuff 
	  <map:match pattern="protected-*.html">
            <map:generate src="private/{1}.xml"/>
	    <map:transform type="session"/>
            <map:transform src="stylesheets/simple-page2html.xsl"/>
            <map:transform type="encodeURL"/>
            <map:serialize/>
	  </map:match>
        </map:act>
        <map:redirect-to uri="login"/>
      </map:match>

      <map:match pattern="*.html">
        <map:generate src="public/{1}.xml"/>
        <map:transform type="session"/>
        <map:transform src="stylesheets/simple-page2html.xsl"/>
        <map:transform type="encodeURL"/>
        <map:serialize/>
      </map:match>
      <map:match pattern="do-logout">
        <map:act type="auth-protect">
          <map:parameter name="handler" value="demohandler"/> 
          <map:act type="auth-logout"/>
          <map:redirect-to uri="index.html"/>
        </map:act>
        <map:redirect-to uri="index.html"/>
      </map:match>
    </map:pipeline>

    <map:pipeline internal-only="true">
      <!-- This is the authentication resource -->
      <map:match pattern="authenticate">
        <map:generate src="userlist.xml"/>
        <map:transform src="stylesheets/authenticate.xsl">
          <map:parameter name="use-request-parameters" value="true"/>
        </map:transform>
        <map:serialize type="xml"/>
      </map:match>
    </map:pipeline>

  </map:pipelines>
</map:sitemap>

-- 
many thanks,
Zoltan Zidarics programmer
PTE University Pecs, Hungary
icq: 43288694


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message