本文整理汇总了Python中tojauth.TOJAuth.check_access方法的典型用法代码示例。如果您正苦于以下问题:Python TOJAuth.check_access方法的具体用法?Python TOJAuth.check_access怎么用?Python TOJAuth.check_access使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tojauth.TOJAuth
的用法示例。
在下文中一共展示了TOJAuth.check_access方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_user_info
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import check_access [as 别名]
def set_user_info(self, uid, nickname, email, avatar, aboutme, cover):
if(
type(uid) != int or
type(nickname) != str or
type(email) != str or
type(avatar) != str or
type(aboutme) != str or
type(cover) != str
):
return 'Eparameter'
if len(nickname) < self.NICKNAME_LEN_MIN:
return 'Enickname_too_short'
elif len(nickname) > self.NICKNAME_LEN_MAX:
return 'Enickname_too_long'
elif len(email) < self.EMAIL_LEN_MIN:
return 'Eemail_too_short'
elif len(email) > self.EMAIL_LEN_MAX:
return 'Eemail_too_long'
elif len(avatar) < self.AVATAR_LEN_MIN:
return 'Eavatar_too_short'
elif len(avatar) > self.AVATAR_LEN_MAX:
return 'Eavatar_too_long'
elif len(aboutme) < self.ABOUTME_LEN_MIN:
return 'Eaboutme_too_short'
elif len(aboutme) > self.ABOUTME_LEN_MAX:
return 'Eaboutme_too_long'
elif len(cover) < self.COVER_LEN_MIN:
return 'Ecover_too_short'
elif len(cover) > self.COVER_LEN_MAX:
return 'Ecover_too_long'
idenid = self.get_idenid_by_uid(uid)
if idenid == None:
return 'Eno_such_uid'
if idenid != TOJAuth.get_current_iden()['idenid']:
TOJAuth.check_access(
self._accessid, TOJAuth.ACCESS_EXECUTE)(lambda x:x)(0)
cur = self.db.cursor()
sqlstr = ('UPDATE "USER" SET "nickname" = %s, "email" = %s, '
'"avatar" = %s, "aboutme" = %s, "cover" = %s WHERE '
'"uid" = %s;')
sqlarr = (nickname, email, avatar, aboutme, cover, uid)
cur.execute(sqlstr, sqlarr)
return 'Success'
示例2: change_user_password
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import check_access [as 别名]
def change_user_password(self, uid, old_password, new_password):
if(
type(uid) != int or
type(old_password) != str or
type(new_password) != str
):
return 'Eparameter'
if len(new_password) < self.PASSWORD_LEN_MIN:
return 'Epassword_too_short'
elif len(new_password) > self.PASSWORD_LEN_MAX:
return 'Epassword_too_long'
idenid = self.get_idenid_by_uid(uid)
if idenid == None:
return 'Eno_such_uid'
if idenid != TOJAuth.get_current_iden()['idenid']:
TOJAuth.check_access(
self._accessid, TOJAuth.ACCESS_EXECUTE)(lambda x:x)(0)
old_passhash = self._password_hash(old_password)
cur = self.db.cursor()
sqlstr = ('SELECT "idenid" FROM "USER" WHERE "uid" = %s '
'AND "passhash" = %s;')
sqlarr = (uid, old_passhash)
cur.execute(sqlstr, sqlarr)
idenid = None
for data in cur:
idenid = data[0]
if idenid == None:
return 'Ewrong_old_password'
new_passhash = self._password_hash(new_password)
sqlstr = ('UPDATE "USER" SET "passhash" = %s WHERE "uid" = %s;')
sqlarr = (new_passhash, uid)
cur.execute(sqlstr, sqlarr)
return 'Success'
示例3: del_mail
# 需要导入模块: from tojauth import TOJAuth [as 别名]
# 或者: from tojauth.TOJAuth import check_access [as 别名]
def del_mail(self, mailid):
if(
type(mailid) != int
):
return 'Eparameter'
uid = mod.UserMg.get_current_uid()
if uid == None:
return 'Eno_uid'
with TOJAuth.change_current_iden(self._idendesc):
mail = self._get_mail(mailid)
if mail == None:
return 'Eno_such_mailid'
if mail['to_uid'] != uid:
TOJAuth.check_access(
self._accessid, TOJAuth.ACCESS_EXECUTE)(lambda x:x)(0)
with TOJAuth.change_current_iden(self._idendesc):
self._del_mail(mailid)
return 'Success'