当前位置: 首页>>代码示例>>Python>>正文


Python OAuth2AccessToken.revoke_all_by_user方法代码示例

本文整理汇总了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()
开发者ID:XPRIYA,项目名称:HMWK2PartB,代码行数:28,代码来源:account.py


注:本文中的r2.models.token.OAuth2AccessToken.revoke_all_by_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。