标签:ldap bbs word password strip wrapper dex *args highlight
import time
user,passwd=‘alex‘,‘abc123‘
def auth(auth_type):
# print(‘auth_func:‘,auth_type)
def outer_wrapper(func):
def wrapper(*args, **kwargs):
if auth_type==‘local‘:
username = input(‘Username‘).strip()
password = input(‘Password‘).strip()
if user == username and passwd == password:
print(‘登录成功‘)
return func(*args, **kwargs)
else:
exit(‘验证失败‘)
elif auth_type==‘ldap‘:
print(‘不会..‘)
return wrapper
return outer_wrapper
def index():
print(‘welcome to index page‘)
@auth(auth_type="local") #home=auth()
def home():
print(‘welcome to home page‘)
return ‘from home‘
@auth(auth_type="ldap")
def bbs():
print(‘welcome to bbs page‘)
index()
print(home())
bbs()
标签:ldap bbs word password strip wrapper dex *args highlight
原文地址:http://www.cnblogs.com/zhangzihong/p/6568950.html