Created
October 25, 2019 13:00
-
-
Save sly01/b58b3ddfe170d486c3fa5343a065bceb to your computer and use it in GitHub Desktop.
Revisions
-
sly01 created this gist
Oct 25, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import functools user = {"username": "ahmet", "access_level": "guest" } def make_secure(access_level): def decarator(func): @functools.wraps(func) def secure_function(*args, **kwargs): if user["access_level"] == access_level: return func(*args, **kwargs) else: return f"No {access_level} permissions for {user['username']}." return secure_function return decorator @make_secure("admin") def get_admin_password(): return "admin: 1234" @make_secure("guest") def get_dashboard_password(): return "user: user_password"