You should do: auth.settings.on_failed_authorization = fff
You were calling the function fff() instead of assigning it to on_failed_authorization. Auth will call the function itself at the appropriate time. Anthony On Wednesday, October 19, 2011 10:21:18 AM UTC-4, d wrote: > > Hi All, > > I am newbie in web2py, and currently work on web service of model > part, say if user is logged in, then then can see the data, otherwise > I want to raise http 403 error but not redirect user to log in page. > Right now seems redirect user to log in page is default option. > > I tried but failed, here is what I tried: > > 1. In Models, db.py > > add > > def fff(): > raise HTTP(403, "Http 403, Login failed or Not logged in") > > auth.settings.on_failed_authorization = fff() > > So, I want to tell web2py if on failed authorization, call function > fff(), which will raise http 403 error > > > 2. In controller, > say a.py > > in a function > > @auth.requires_login() > def aaa(): > ........ > > so it says function aaa required logged in, and if not logged in, it > should see auth.settings.on_failed_authorization = fff() in db.py > > but somehow it did not works, because for all the controller and > normal view, it always display this http 403 error, I dont know where > is the problem, can someone help me, thanks a lot!

