I have add code in my db.py to add extra field before the auth.define_tables(username=False, signature=True)
:
auth.settings.extra_fields['auth_user'] = (
[Field('user_type',label="reg_type",default="Stu", requires=IS_IN_SET(['Stu, 'Com'],multiple=False))])
and I want to do some authentication in my action like the following:
@auth.requires(auth.user.user_type=="Stu",requires_login=True)
define someaction:
code
However I get a error ticket when I run my application.
'NoneType' object has no attribute 'user_type'
And I have read the manual book
@auth.requires also takes an optional argument requires_login which defaults to True. If set to False, it does not require login before evaluating the condition as true/false. The condition can be a boolean value or a function evaluating to boolean.
Note that access to all functions apart from the first one is restricted based on permissions that the visitor may or may not have.
If the visitor is not logged in, then the permission cannot be checked; the visitor is redirected to the login page and then back to the page that requires permissions.
So I can't understand what results in the error. Thank you.