Hi annet

Saying it's useless I meant that setting the message after logging
in , I didn't mean to be mean at all, sorry that you misunderstood
me :)

Now let's rethink you solution :

It will work right ? but when ?
it will work if you just in the index page made something like:


def index():
    if auth.is_logged_in():
        response.flash = auth.messages.logged_in
    return dict(message=T('Hello World'))

Now see ..... you need an extra check to make sure that user is logged
in
this extra check has to be at all functions .

now if you've something like:

@auth.requires_login()
def go():
    return dict(message=T('Hello World'))

and you just put the link into browser
http://127.0.0.1/default/go
when you're not logged in
what will happen ?

you will be redirected to login page then after succefull login you'll
be returned to the page "go"
which has no login welcome flash message set :)

Now the solution is  to put
 if auth.is_logged_in():
        response.flash = auth.messages.logged_in

 at the controller level so you can move the code out of every
controller function
Now what will happen ?!!!!
every time when you visit a page you'll see the welcome message :)
moreover you need to put it all controllers you've

and at last

the logout will not work if you've already a flash message in the page
[index]

So , your solution may  work but it's not general , it's just work for
you  and I was talking generally :D


On Jun 3, 9:15 pm, annet <[email protected]> wrote:
> > This's not working !! you need to set the message before actually logged in 
> > !!
>
> Why is that? I welcome a user who logs in so setting
> auth.messages.logged_in works. When does auth.user provide you with
> values for first_name and last_name in your solution? Before logging
> in?
>
> > your solution just set the message after user is actually logged in so
> > it's useless
>
> Cheers!
>
> > moreover, setting the logout message will not work, unless the index
> > page itself has no flash message set or else the flash message in
> > index age will override yours
>
> In my case (with login_next and logout_url set) both the login message
> and the logout message works, so who are you to tell me that it
> doesn't work. As I said:
>
> > It's probably not the most elegant of solutions, but in db.py I simply
> > set:
>
> Kind regards,
>
> Annet.

Reply via email to