本文整理汇总了Python中social_auth.models.UserSocialAuth.allowed_to_disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python UserSocialAuth.allowed_to_disconnect方法的具体用法?Python UserSocialAuth.allowed_to_disconnect怎么用?Python UserSocialAuth.allowed_to_disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类social_auth.models.UserSocialAuth
的用法示例。
在下文中一共展示了UserSocialAuth.allowed_to_disconnect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: disconnect
# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import allowed_to_disconnect [as 别名]
def disconnect(self, user, association_id=None):
"""Deletes current backend from user if associated.
Override if extra operations are needed.
"""
name = self.AUTH_BACKEND.name
if UserSocialAuth.allowed_to_disconnect(user, name, association_id):
if association_id:
UserSocialAuth.get_social_auth_for_user(user).get(id=association_id).delete()
else:
UserSocialAuth.get_social_auth_for_user(user).filter(provider=name).delete()
else:
raise NotAllowedToDisconnect()
示例2: disconnect
# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import allowed_to_disconnect [as 别名]
def disconnect(self, user, association_id=None):
"""Deletes current backend from user if associated.
Override if extra operations are needed.
"""
name = self.AUTH_BACKEND.name
if UserSocialAuth.allowed_to_disconnect(user, name, association_id):
do_revoke = setting('SOCIAL_AUTH_REVOKE_TOKENS_ON_DISCONNECT')
filter_args = {}
if association_id:
filter_args['id'] = association_id
else:
filter_args['provider'] = name
instances = UserSocialAuth.get_social_auth_for_user(user)\
.filter(**filter_args)
if do_revoke:
for instance in instances:
instance.revoke_token(drop_token=False)
instances.delete()
else:
raise NotAllowedToDisconnect()