本文整理汇总了Python中r2.models.token.OAuth2AccessToken.revoke_all_by_user方法的典型用法代码示例。如果您正苦于以下问题:Python OAuth2AccessToken.revoke_all_by_user方法的具体用法?Python OAuth2AccessToken.revoke_all_by_user怎么用?Python OAuth2AccessToken.revoke_all_by_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r2.models.token.OAuth2AccessToken
的用法示例。
在下文中一共展示了OAuth2AccessToken.revoke_all_by_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _banned
# 需要导入模块: from r2.models.token import OAuth2AccessToken [as 别名]
# 或者: from r2.models.token.OAuth2AccessToken import revoke_all_by_user [as 别名]
def _banned(self, value):
if value and not self._banned:
self.state |= 1
# Invalidate all cookies by changing the password
# First back up the password so we can reverse this
self.backup_password = self.password
# New PW doesn't matter, they can't log in with it anyway.
# Even if their PW /was/ 'banned' for some reason, this
# will change the salt and thus invalidate the cookies
change_password(self, 'banned')
# deauthorize all access tokens
from r2.models.token import OAuth2AccessToken
from r2.models.token import OAuth2RefreshToken
OAuth2AccessToken.revoke_all_by_user(self)
OAuth2RefreshToken.revoke_all_by_user(self)
elif not value and self._banned:
self.state &= ~1
# Undo the password thing so they can log in
self.password = self.backup_password
# They're on their own for OAuth tokens, though.
self._commit()