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