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

Reply via email to