Hallo,
I'm asking for help for followed task:
"""
Realize a function-decorator , which is checking an access according to USERNAME
All USERNAMEs are saved as global in the List USERS
If User is agree for authorisation - he should input his username (saved as global)
Funktion should use two decorators: one for checking of authorisation, second - for check of access
"""
Why is error outputed?:
I'm asking for help for followed task:
"""
Realize a function-decorator , which is checking an access according to USERNAME
All USERNAMEs are saved as global in the List USERS
If User is agree for authorisation - he should input his username (saved as global)
Funktion should use two decorators: one for checking of authorisation, second - for check of access
"""
Why is error outputed?:
USERS = ['admin', 'guest', 'director', 'root', 'superstar'] yesno = input(""" Input Y if you want to authorisate yourself or input N if you want to work as an anonyme User """) auth = yesno == "Y" if auth: username = input("Input your username:") def is_auth(func): def wrapper(): if auth: print("User is authorised") func() else: print("User is not authorised. Function will not performed") return wrapper @is_auth @has_access def from_db(): print("some data from database") from_db() ###: def has_access(func): def wrapper(): if username in USERS: print("Authorised as", username) func() else: print("Access for user", username, "is not allowed") return wrapperI would like to ask for helping to correct the code