if not auth.is_logged_in():
user_obj = Storage(user_table._filter_fields(Users.find_by_id
(user_id)[0], id=True))
session.auth = Storage(user=user_obj, last_visit=request.now,
expiration=2600)
where Users.find_by_id(user_id) assume it's db(db.users.id ==
user_id).select()
Even though it seems to work, I don't think it is correct (because if
it is THAT simple for everyone to
create an auth object then he can hack the system).
I checked the auth.requires_login but I couldn't figure it out.
So, how can I create a new session programmatically (like the login
page does)?
from gluon.storage import Storage
session.auth=Storage()
session.auth.user = db(db.auth_user.id==logged_in_user_id).select
().first()
session.auth.user_id = session.auth.user.id
session.auth.last_visit = request.now
set session.auth=None on logout.
@auth.requires_login()
def admin_area():
...do stuf...
return ....
If a user creates a session by hand, he can access that area right?
El 31/01/2010 16:08, Jon Romero escribi�:
--
Alejandro Fanjul Fdez.
alex....@gmail.com
www.mhproject.org
El 31/01/2010 17:24, Jon Romero escribi�:
--
>All auth does on successful login is:
>from gluon.storage import Storage
>session.auth=Storage()
>session.auth.user = db(db.auth_user.id==logged_in_user_id).select
().first()
>session.auth.user_id = session.auth.user.id
>session.auth.last_visit = request.now
>set session.auth=None on logout.
>
> >>> So, how can Icreatea new session programmatically (like the login
> >>> page does)?
>
> >> --
> >> Alejandro Fanjul Fdez.
> >> alex.fan...@gmail.comwww.mhproject.org
>
> --
> Alejandro Fanjul Fdez.