Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    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()