Ejemplo n.º 1
0
    def getAssociation(self, server_url, handle=None):
        """Return stored assocition"""
        oid_associations = UserSocialAuth.get_oid_associations(server_url,
                                                               handle)
        associations = [association
                        for assoc_id, association in oid_associations
                        if association.getExpiresIn() > 0]
        expired = [assoc_id for assoc_id, association in oid_associations
                   if association.getExpiresIn() == 0]

        if expired:  # clear expired associations
            UserSocialAuth.delete_associations(expired)

        if associations:  # return most recet association
            return associations[0]