You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Runar <gr...@gmail.com> on 2008/02/26 03:44:37 UTC

[2.0.1] login form w/registration of new users and logout (newbie)

Hi,
I have seen earlier answers on this list about including a login form on
other pages.
However those answers seem to pertain to earlier versions, I am using Lenya
2.0 / 2.0.1 now.

-Description-
However, I have a problem using this - since trying to log in will redirect
to another page with the ac.login usecase.
This usecase has a continuation parameter, which I don't know if is
necessary to actually perform the login.
I would like very much to get the login effectuated immediately from the
included login form, and not having to step
via the full screen login form from the ac.login usecase.

-Questions-
What is missing from my login form to accomplish this?
Also, if I wanted the ac.logout to be immediate in stead of stepping into
the full screen/page of the session history,
but rather just have a direct logout?

-Some notes-
In earlier posts adressing this, as well as from the information by
solprovider - it's referring to the old way (?) where
the login usecase would be matched in the sitemap, and where the
lenya.steprequest parameter was used as well.
Without the referrerQueryString paramater, it will add the string "null" to
the "index.html" URL - "index.htmlnull" when logging in.

-My attempt to accomplish the login form-
I have the same need as many others to include the login form on some/any
page, and have included the following in pubs/default/xslt/page2xhtml-
homepage.xsl

<xsl:choose>
<xsl:when test="$userid">
<div>
<span style="font-size: small; margin-right: 2em;">Logged in as
</span><strong><xsl:value-of select="$username"/></strong> (<xsl:value-of
select="$userid"/>)
<a style="margin-left: 4em;" href="?lenya.usecase=ac.logout">Logout</a>
</div>
</xsl:when>
<xsl:otherwise>
        <form name="login" id="login" method="get" action="?lenya.usecase=
ac.login">
          <div style="float: left; margin-right: 4em;">
            <label for="name">Username: </label>
            <input class="lenya-form-element" name="username" type="text"
value="" />
            <label for="password"> Password: </label>
              <input class="lenya-form-element" name="password"
type="password" />
              <input class="lenya-form-element" name="referrerQueryString"
type="hidden" value="" />
            <input name="submit" type="submit" value="Login" />
          </div>
        </form>
<a href="?lenya.usecase=admin.addUser&amp;className=
org.apache.lenya.ac.file.FileUser&amp
;userType=Local+User&amp;input-add_user=Local+User">Register new user</a>
<div style="clear: both;"></div>
</xsl:otherwise>
</xsl:choose>

Just for completeness for others wanting to do the same - further up in the
page2xhtml-homepage.xsl file I have:
  <xsl:param name="userid"/>
  <xsl:param name="username"/>

Then I have added some more parameters in the matcher in
pubs/default/sitemap.xmap for the <map:match pattern="lenyabody-*/*/*/*/**">
   <map:parameter name="userid" value="{access-control:user-id}"/>
   <map:parameter name="username" value="{access-control:user-name}"/>

For anybody to be able to register a new user I have changed the
pubs/default/config/access-control/usecase-policies.xml with the following
  <usecase id="admin.addUser">
    <role id="visit" method="grant"/>
    <role id="admin" method="grant"/>
  </usecase>


All of this makes the xhtml front page (of resourcetype homepage) show the
login form and registration link if not logged in,
and the user information about what user is logged in as well as a logout
link when logged in. Pretty standard stuff.
New registrations, logout and login work just fine - but for now the login
will be redirected to a full screen login usecase.

Hope this information is complete enough to help others, and thanks for any
help on getting the login to perform immediately.

-Runar

Re: [2.0.1] login form w/registration of new users and logout (newbie)

Posted by Gringinho <gr...@gmail.com>.
Thank you, Andreas.

Funnily enough, I was just reading about this exact approach when you
answered.
This makes is quite obvious when understanding the usecase module and login
usecases.

Cheers,
Gringinho


On Tue, Feb 26, 2008 at 5:44 AM, Andreas Hartmann <an...@apache.org>
wrote:

> Hi Runar,
>
> Runar schrieb:
> > Hi,
> > I have seen earlier answers on this list about including a login form on
> > other pages.
> > However those answers seem to pertain to earlier versions, I am using
> > Lenya 2.0 / 2.0.1 now.
> >
> > -Description-
> > However, I have a problem using this - since trying to log in will
> > redirect to another page with the ac.login usecase.
> > This usecase has a continuation parameter, which I don't know if is
> > necessary to actually perform the login.
> > I would like very much to get the login effectuated immediately from the
> > included login form, and not having to step
> > via the full screen login form from the ac.login usecase.
> >
> > -Questions-
> > What is missing from my login form to accomplish this?
>
> you can declare a non-view version of the ac.login usecase (it's located
> in the acusecases module):
>
> http://lenya.apache.org/docs/2_0_x/reference/usecase-framework/index.html#Implement+the+View
> "The view of a usecase is optional. If you omit the view declaration, no
> screen is presented to the user."
>
> Here's some info how to declare a usecase:
> http://lenya.apache.org/docs/2_0_x/tutorials/usecase/part2.html
>
> > Also, if I wanted the ac.logout to be immediate in stead of stepping
> > into the full screen/page of the session history,
> > but rather just have a direct logout?
>
> You can use the same approach as above.
>
> HTH,
>
> -- Andreas
>
>
>
> --
> Andreas Hartmann, CTO
> BeCompany GmbH
> http://www.becompany.ch
> Tel.: +41 (0) 43 818 57 01
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
>
>

Re: [2.0.1] login form w/registration of new users and logout (newbie)

Posted by Andreas Hartmann <an...@apache.org>.
Hi Runar,

Runar schrieb:
> Hi,
> I have seen earlier answers on this list about including a login form on 
> other pages.
> However those answers seem to pertain to earlier versions, I am using 
> Lenya 2.0 / 2.0.1 now.
> 
> -Description-
> However, I have a problem using this - since trying to log in will 
> redirect to another page with the ac.login usecase.
> This usecase has a continuation parameter, which I don't know if is 
> necessary to actually perform the login.
> I would like very much to get the login effectuated immediately from the 
> included login form, and not having to step
> via the full screen login form from the ac.login usecase.
> 
> -Questions-
> What is missing from my login form to accomplish this?

you can declare a non-view version of the ac.login usecase (it's located 
in the acusecases module):
http://lenya.apache.org/docs/2_0_x/reference/usecase-framework/index.html#Implement+the+View
"The view of a usecase is optional. If you omit the view declaration, no 
screen is presented to the user."

Here's some info how to declare a usecase:
http://lenya.apache.org/docs/2_0_x/tutorials/usecase/part2.html

> Also, if I wanted the ac.logout to be immediate in stead of stepping 
> into the full screen/page of the session history,
> but rather just have a direct logout?

You can use the same approach as above.

HTH,

-- Andreas



-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org