Indeed, I don't. That's the solution I actually came to before I
rechecked the forum! Thanks much.
For future reference, I checked whether the login_form was already
defined as follows (the two instances of the form are formatted
differently):
{{if not 'login_form' in locals():}}
form code
{{pass}}
On Nov 14, 4:48 pm, Anthony <[email protected]> wrote:
> Why do you need two distinct login forms in the same page? Can it be just
> one login form (i.e., one call to auth.login()) that you display twice? For
> example:
>
> def myaction():
> [do stuff]
> return dict(..., login_form=auth.login())
>
> View:
>
> {{=login_form # show it here}}
> ...
> {{=login_form # show it somewhere else}}
>
> Anthony
>
>
>
>
>
>
>
> On Monday, November 14, 2011 4:29:24 PM UTC-5, Chris wrote:
>
> > After doing some more digging, it appears that each time you call
> > auth.login(), you generate a new formkey. The first formkey must get
> > overloaded, so the XSRF protection prevents either form from
> > submitting.
>
> > Any way I can get around this? Sample code:
>
> > {{top_login_form = auth.login()}}
> > {{=top_login_form.custom.begin}}
> > {{=top_login_form.custom.widget.email}}
> > {{=top_login_form.custom.widget.password}}
> > <input type="image" src="/init/static/images/buttons/
> > login.png" id="loginBtn" value="Log In" />
> > {{=top_login_form.custom.end}}
> > h
> > {{top_login_form2 = auth.login()}}
> > {{=top_login_form2.custom.begin}}
> > {{=top_login_form2.custom.widget.email}}
> > {{=top_login_form2.custom.widget.password}}
> > <input type="image" src="/init/static/images/buttons/
> > login.png" id="loginBtn" value="Log In" />
> > {{=top_login_form2.custom.end}}
>
> > On Nov 14, 4:24 pm, Chris <[email protected]> wrote:
> > > Cool, thanks guys.
>
> > > I do have decorators on certain login-only pages, but I want a page
> > > that's visible to both members and guests. The idea is to have a login
> > > form that shows up only under certain circumstances.
>
> > > I've done some further tests, and I think auth.login() is working in-
> > > template, but it doesn't seem to work if there's already a login form
> > > on the page. Can I only call auth.login() once?
>
> > > Here's how I'm attempting to do login now:
>
> > > {{if user_id:}}
> > > <span>Welcome {{=user_current().first_name }}!</span>
> > > <form>
> > > <input type="button" id="logoutBtn" value="Log Out"
> > > onclick="window.location.href =
> > > '{{=URL('default','user',args=['logout'])}}';" />
> > > </form>
> > > {{else:}}
> > > {{top_login_form = auth.login()}}
> > > {{=top_login_form.custom.begin}}
> > > {{=top_login_form.custom.widget.email}}
> > > {{=top_login_form.custom.widget.password}}
> > > {{top_login_form.custom.widget.login}}
> > > <input type="image" src="/init/static/images/buttons/
> > > login.png" id="loginBtn" value="Log In" />
> > > <!--input type="text" placeholder="email" name="email">
> > > <input type="password" placeholder="password"
> > > name="password">
> > > <input type="image" src="/init/static/images/buttons/
> > > login.png" id="loginBtn" value="Log In"-->
> > > {{=top_login_form.custom.end}}
> > > {{pass}}
>
> > > On Nov 14, 4:07 pm, Anthony <[email protected]> wrote:
>
> > > > auth.login() handles its own processing, so you don't need to do
> > > > login_form.accepts(). So, just use auth.login() wherever you need it.
>
> > > > Anthony
>
> > > > On Monday, November 14, 2011 3:58:52 PM UTC-5, Chris wrote:
>
> > > > > Hello,
>
> > > > > I'd like to make a login form and have it be accessible in multiple
> > > > > pages, without having to rewrite the same code in every single
> > > > > controller action:
>
> > > > > login_form = auth.login()
> > > > > if login_form.accepts(...
>
> > > > > Is this possible?
>
> > > > > Thanks,
> > > > > Chris