Oh Thanks Massimo I completely forgot about the
"auth.settings.login_url...".
Here my new code:

auth.settings.login_url=URL(r=request,f='login')

def login():
    return dict(form=auth.login(next="profile"))

@auth.requires_login()
def profile():
    return dict(Welcome="Welcome")

How can I retrieve the response.flash() message in this case to let
the user know that the login failed since here i recreate a new
request and i guest the rsponse is lost... Do you have any forwarding
mechanism ?

In the login.html file i have this:
{{if response.flash:}}{{=response.flash}}{{pass}}

I guess I don't retrieve the response.flash anymore because it is the
new request.

Do you have any idea how to print the flash message when the login
failed based on my code? or is there any other solution more
efficient ?

Thanks for your help !

On Feb 22, 3:07 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> In your code
>
> @auth.requires_login()
> def profile():
>     if not auth.is_logged_in():
>         return dict(form=auth.login(next="login"))
>     else:
>         return dict(msg="Welcome")
>
> because of
>
>     @auth.requires_login()
>
>  auth.is_logged_in() is always true
>
> The validator, is user is not logged in, redirects to
>
>     auth.settings.login_url
>
> you can set it
>
>     auth.settings.login_url=URL(r=request,f='login')
>
> Hope this answers the question.
>
> Massimo
>
> On Feb 22, 12:04 pm, Yannick <ytchatch...@gmail.com> wrote:
>
> > Hello mate,
> > Here is what I have in my controller:
>
> > def login():
> >     formlog = auth.login(next="profile")
> >     return dict(form=formlog)
>
> > @auth.requires_login():
> > def profile():
> >     if not auth.is_logged_in():
> >         return dict(form=auth.login(next="login"))
> >     else:
> >         return dict(msg="Welcome")
>
> > I have two problem here:
> > - First; here basically I'm just trying to login and if the login
> > failed the page is redirect to the login page with a feedback
> > message... when the login Authentication pass I can successfully
> > access the Profile page with no problem BUT when the login
> > Authentication failed I'm redirect to this link "http://127.0.0.1:8000/
> > App../default/user/login" with a message "invalid function". I
> > understand the message because i don't have any action named "User"
> > define on my controller. I'm wondering why i got redirect to that
> > link ? is there something I'm doing wrong in my code ? I guess is how
> > the tools.py is internally implement and i understand that we must not
> > change this code... Is there something i can do to fix that problem in
> > my code ??
>
> > - Second; the "@auth.requires_login(): " doesn't seems to work since I
> > have an error message on the colon and even when i remove the colon i
> > have no error message but still can able to access the profile
> > action.... Any idea please ?
>
> > Do you please have a better way of doing what I'm trying to solve.
>
> > Thanks for your attention.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to