user_state = False
def login(auth_tpye):
def out(func):
def inner(*args,**kwargs):
global user_state
db = {'kingforn': 'abc123', 'alex': 'abc!@#'}
if user_state == False:
_username = input('输入用户名:')
_password = input('输入密码:')
if _username in db and _password == db[_username]:
print('验证通过,welcome:', _username)
user_state = True
else:
print('wrong username or password')
else:
print('用户已登陆,通过验证')
if user_state:
func(*args,**kwargs)
return inner
return out
def home():
print("-----首页-----")
@login
def ameriac('qq'):
print("-----美国专区-----",args)
@login
def jp(’wx‘):
print("-----日韩专区-----")
def cn():
print("-----大陆专区-----")
#此时产品经理有提出需求了,增加 qq,微信等认证方式