Forum OpenACS Development: Problem with acs_user::get_element

Hi all,
I am using said api to get the current user
information.But it gives error if no user is logged in.
Can any one could suggest solution to this.

Thanks and Regards,
-Amruta

Collapse
Posted by Gustaf Neumann on
you should proved the exact call with the used parameters. For example, if you do not provide the user_id, the api call tries to get the information for the user, who is currently logged in.
Collapse
Posted by Amruta Lakade on
Hi Gustaf,
Thanks for the reply.

I am using the api to know the name of logged-in user only.
At the moment of calling the api if i don't know the user_id then how should I provide it?

-Amruta

Collapse
Posted by Gustaf Neumann on
One can get the user_id of the current user via "ad_conn user_id". If the result of "ad_conn user_id" is 0, no user is currently logged-in in this thread.
Collapse
Posted by Mark Aufflick on
This is not *quite* correct. There are two user_id values available from ad_conn: user_id and untrusted_user_id

The difference in behaviour is this:


                    no user     user logged in    user logged in
                    logged_in   and not expired   but expired
user_id                0            the id             0
untrusted_user_id      0            the id          the id

It's important to know the difference because otherwise your users will have the confusion of the "logged in as..." showing that they are logged in, but your code relying solely on ad_conn user_id behaving as though they are not logged in.

Just thought it worth clarifying.
Collapse
Posted by Amruta Lakade on
Hey thanks,
The problem is solved :)
Thanks again.
-Amruta