本文整理汇总了Python中model.User.check_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.check_user方法的具体用法?Python User.check_user怎么用?Python User.check_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.check_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: isAuthor
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import check_user [as 别名]
def isAuthor(self):
user_name_cookie = self.get_cookie('username','')
user_pw_cookie = self.get_cookie('userpw','')
if user_name_cookie and user_pw_cookie:
from model import User
user = User.check_user(user_name_cookie, user_pw_cookie)
else:
user = False
return user
示例2: authorized_handler
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import check_user [as 别名]
def authorized_handler(self, *args, **kw):
request = self.request
user_name_cookie = self.get_cookie('username','')
user_pw_cookie = self.get_cookie('userpw','')
if user_name_cookie and user_pw_cookie:
from model import User
user = User.check_user(user_name_cookie, user_pw_cookie)
else:
user = False
if request.method == 'GET':
if not user:
self.redirect(url)
return False
else:
handler(self, *args, **kw)
else:
if not user:
self.error(403)
else:
handler(self, *args, **kw)
示例3: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import check_user [as 别名]
def post(self):
try:
name = self.get_argument("name")
password = self.get_argument("password")
except:
self.redirect('%s/admin/login'% BASE_URL)
return
if name and password:
has_user = User.check_has_user()
if has_user:
#check user
password = md5(password.encode('utf-8')).hexdigest()
user = User.check_user( name, password)
if user:
#logging.error('user ok')
self.set_cookie('username', name, path="/", expires_days = 365 )
self.set_cookie('userpw', password, path="/", expires_days = 365 )
self.redirect('%s/admin/'% BASE_URL)
return
else:
#logging.error('user not ok')
self.redirect('%s/admin/login'% BASE_URL)
return
else:
#add new user
newuser = User.add_new_user( name, password)
if newuser:
self.set_cookie('username', name, path="/", expires_days = 365 )
self.set_cookie('userpw', md5(password.encode('utf-8')).hexdigest(), path="/", expires_days = 365 )
self.redirect('%s/admin/'% BASE_URL)
return
else:
self.redirect('%s/admin/login'% BASE_URL)
return
else:
self.redirect('%s/admin/login'% BASE_URL)