本文整理汇总了Python中torlite.model.muser.MUser.check_user方法的典型用法代码示例。如果您正苦于以下问题:Python MUser.check_user方法的具体用法?Python MUser.check_user怎么用?Python MUser.check_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torlite.model.muser.MUser
的用法示例。
在下文中一共展示了MUser.check_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UserHandler
# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import check_user [as 别名]
class UserHandler(BaseHandler):
def initialize(self):
self.muser = MUser()
self.user_name = self.get_current_user()
def get(self, url_str):
url_arr = url_str.split('/')
if url_str == 'regist':
if self.get_current_user():
self.redirect('/')
else:
self.__to_register__()
elif url_str == 'login':
self.to_login()
elif url_str == 'info':
self.show_info()
elif url_str == 'logout':
self.logout()
elif url_str == 'changepass':
self.changepass()
elif url_str == 'changeinfo':
self.change_info()
elif url_arr[0] == 'changeprivilege':
self.change_privilege(url_arr[1])
elif url_str == 'find':
self.to_find()
elif url_arr[0] == 'find':
self.find(url_arr[1])
def post(self, url_str):
url_arr = url_str.split('/')
if url_str == 'regist':
self.register()
elif url_str == 'login':
self.login()
elif url_str == 'changepass':
self.changepassword()
elif url_str == 'changeinfo':
self.changeinfo()
elif url_str == 'find':
self.post_find()
elif url_arr[0] == 'changeprivilege':
self.changeprivilege(url_arr[1])
@tornado.web.authenticated
def changepassword(self):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
uu = self.muser.check_user(self.user_name, post_data['rawpass'][0])
print(uu)
if uu == 1:
self.muser.update_pass(self.user_name, post_data['user_pass'][0])
self.redirect(('/user/info'))
else:
return False
@tornado.web.authenticated
def changeinfo(self):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
uu = self.muser.check_user(self.user_name, post_data['rawpass'][0])
print(uu)
if uu == 1:
self.muser.update_info(self.user_name, post_data['user_email'][0])
self.redirect(('/user/info'))
else:
return False
@tornado.web.authenticated
def changeprivilege(self, xg_username):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
self.muser.update_privilege(xg_username, post_data['privilege'][0])
self.redirect(('/user/info'))
@tornado.web.authenticated
def logout(self):
self.clear_all_cookies()
self.redirect('/')
@tornado.web.authenticated
def changepass(self):
self.render('tplite/user/changepass.html',
user_info=self.muser.get_by_id(self.user_name))
@tornado.web.authenticated
def change_info(self):
self.render('tplite/user/changeinfo.html',
user_info=self.muser.get_by_id(self.user_name))
@tornado.web.authenticated
def change_privilege(self, xg_username):
self.render('tplite/user/changeprivilege.html',
#.........这里部分代码省略.........
示例2: UserHandler
# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import check_user [as 别名]
class UserHandler(BaseHandler):
def initialize(self):
self.init()
self.muser = MUser()
self.user_name = self.get_current_user()
self.tmpl_router = 'user'
def get(self, url_str):
url_arr = self.parse_url(url_str)
if url_str == 'regist':
if self.get_current_user():
self.redirect('/')
else:
self.__to_register__()
elif url_str == 'login':
self.to_login()
elif url_str == 'info':
self.show_info()
elif url_str == 'logout':
self.logout()
elif url_str == 'reset-password':
self.to_reset_password()
elif url_str == 'changepass':
self.changepass()
elif url_str == 'changeinfo':
self.change_info()
elif url_str == 'reset-passwd':
if self.gen_passwd():
pass
else:
self.redirect(config.site_url)
elif url_arr[0] == 'changeprivilege':
self.change_privilege(url_arr[1])
elif url_str == 'find':
if self.tmpl_router == "user":
self.to_find()
else:
self.p_to_find()
elif url_arr[0] == 'find':
self.find(url_arr[1])
elif url_arr[0] == 'delete_user':
self.delete(url_arr[1])
def post(self, url_str):
url_arr = self.parse_url(url_str)
if url_str == 'regist':
self.register()
elif url_str == 'login':
self.login()
elif url_str == 'changepass':
self.changepassword()
elif url_arr[0] == 'changepass':
self.p_changepassword()
elif url_str == 'changeinfo':
self.changeinfo()
elif url_arr[0] == 'changeinfo':
self.p_changeinfo()
elif url_str == 'find':
self.post_find()
elif url_arr[0] == 'find':
self.find(url_arr[1])
elif url_str == 'reset-password':
self.reset_password()
elif url_arr[0] == 'changeprivilege':
self.changeprivilege(url_arr[1])
@tornado.web.authenticated
def p_changepassword(self):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
uu = self.muser.check_user(self.user_name, post_data['rawpass'][0])
if uu == 1:
self.muser.update_pass(self.user_name, post_data['user_pass'][0])
output = {
'changepass ': uu,
}
else:
output = {
'changepass ': 0,
}
return json.dump(output, self)
@tornado.web.authenticated
def p_changeinfo(self):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
uu = self.muser.check_user(self.user_name, post_data['rawpass'][0])
if uu == 1:
#.........这里部分代码省略.........
示例3: UserHandler
# 需要导入模块: from torlite.model.muser import MUser [as 别名]
# 或者: from torlite.model.muser.MUser import check_user [as 别名]
class UserHandler(BaseHandler):
def initialize(self):
self.muser = MUser()
self.user_name = self.get_current_user()
def get(self, url_str):
url_arr = url_str.split('/')
if url_str == 'regist':
if self.get_current_user():
self.redirect('/')
else:
self.__to_register__()
elif url_str == 'login':
self.to_login()
elif url_str == 'info':
self.show_info()
elif url_str == 'logout':
self.logout()
def post(self, url_str):
url_arr = url_str.split('/')
if url_str == 'regist':
self.register()
elif url_str == 'login':
self.login()
elif url_str == 'changepass':
self.changepassword()
@tornado.web.authenticated
def changepassword(self):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
uu = self.muser.check_user(self.user_name, post_data['rawpass'][0])
print(uu)
if uu == 1:
self.muser.update_pass(self.user_name, post_data['user_pass'][0])
self.redirect(('/user/info'))
else:
return False
@tornado.web.authenticated
def logout(self):
self.clear_all_cookies()
self.redirect('/')
@tornado.web.authenticated
def show_info(self):
self.render('tplite/user/info.html',
user_info = self.muser.get_by_id(self.user_name))
def to_login(self):
if self.get_current_user():
self.redirect('/')
else:
kwd = {
'pager': '',
}
self.render('tplite/user/login.html', kwd=kwd)
def register(self):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
form = SumForm(self.request.arguments)
if form.validate():
if self.muser.insert_data(post_data) == True:
self.redirect('/user/login')
else:
self.render('html/404.html')
self.set_status(400)
def __to_register__(self):
kwd = {
'pager': '',
}
self.render('tplite/user/regist.html', kwd=kwd)
def login(self):
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
if 'next' in post_data:
next_url = post_data['next'][0]
else:
next_url = ''
u_name = post_data['user_name'][0]
u_pass = post_data['user_pass'][0]
#.........这里部分代码省略.........