Thanks Massimo, it work fine but for some reason I can't make it work
with MySql Server DB... Here is the error message I get, please look
this thread:
http://groups.google.com/group/web2py/browse_thread/thread/f24f80e9e299aa88


Thanks,
Yannick P.
On Feb 26, 9:10 pm, Yannick <ytchatch...@gmail.com> wrote:
> Hello Massimo,
> I just sent you the application.
> I expect to see a feedback message when the user failed to login.
>
> Thanks for your help and attention.
>
> Cheers,
> Yannick P.
>
> On Feb 24, 1:00 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > Your example works great for me and I get the flash (bad login or
> > perfect).
>
> > Send me the whole app (perhaps something else is messing this up) but
> > let me know in detail what the problem is. Perhaps you expect
> > something different than I do.
>
> > massimo
>
> > On Feb 23, 8:15 pm, Yannick <ytchatch...@gmail.com> wrote:
>
> > > Thanks Massimo, I appreciate your help but i think maybe i don't
> > > understand or there is something I'm doing wrong... Here is my code
> > > please let me know where I'm wrong because i did set
> > > "auth.messages.invalid_login"
>
> > > auth.settings.on_failed_authorization=URL(r=request,f='error')
> > > auth.settings.login_url=URL(r=request,f='login')
> > > auth.messages.invalid_login= 'Bad Login'
> > > auth.messages.logged_in = 'Perfect'
>
> > > def login():
> > >     return dict(form=auth.login(next="profile"))
>
> > > @auth.requires_login()
> > > def profile():
> > >     return dict()
>
> > > You said i should set "session.flash" before redirect... Where should
> > > I set it since the redirect is done implicitly inside tools.py...
> > > I really want to understand how to make this work without touching
> > > anything in the tools.py code..
>
> > > Thanks for your attention !
>
> > > Yannick P.
>
> > > On Feb 23, 1:34 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > Just set these:
>
> > > > auth.messages.invalid_login
> > > > auth.messages.logged_in
>
> > > > Massimo
>
> > > > On Feb 22, 9:05 pm, Yannick <ytchatch...@gmail.com> wrote:
>
> > > > > Thanks Massimo and Yarko,
> > > > > Theproblemhere is the redirect is done implicitly using the
> > > > > decorator pattern... It is done inside the method "requires_login()"
> > > > > of tools.py.  I guess one solution should have been to put the
> > > > > session.flash message inside the "requires_login()" BUT I'm not allow
> > > > > to do so...
> > > > > Do you see what i mean ?
>
> > > > > thanks !
>
> > > > > On Feb 22, 8:21 pm, Yarko Tymciurak <yark...@gmail.com> wrote:
>
> > > > > > yes, and set session flash in your controller (not your view);
>
> > > > > > On Feb 22, 3:32 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > > > I am not sure I fully understand so I give you two answers.
>
> > > > > > > A) Before redirection you should set
>
> > > > > > >    session.flash="message"
>
> > > > > > > instead of
>
> > > > > > >    response.flash="message"
>
> > > > > > > The former is copied in the latter automatically before 
> > > > > > > redirection.
>
> > > > > > > B) The messages generated by the auth method all set session.flash
> > > > > > > before redirection. The messages are customizable. You can find a 
> > > > > > > list
> > > > > > > in gluon.tools.py
>
> > > > > > > Massimo
>
> > > > > > > On Feb 22, 2:52 pm, Yannick <ytchatch...@gmail.com> wrote:
>
> > > > > > > > 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 twoproblemhere:
> > > > > > > > > > - 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 noproblemBUT 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 
> > > > > > > > > > thatproblemin
> > > > > > > > > > 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