def revoke_oauth_access(self, external_account, auth, save=True): """Revoke all access to an ``ExternalAccount``. TODO: This should accept node and metadata params in the future, to allow fine-grained revocation of grants. That's not yet been needed, so it's not yet been implemented. """ for node in self.get_nodes_with_oauth_grants(external_account): try: addon_settings = node.get_addon(external_account.provider, deleted=True) except AttributeError: # No associated addon settings despite oauth grant pass else: addon_settings.deauthorize(auth=auth) if User.find(Q('external_accounts', 'eq', external_account._id)).count() == 1: # Only this user is using the account, so revoke remote access as well. self.revoke_remote_oauth_access(external_account) for key in self.oauth_grants: self.oauth_grants[key].pop(external_account._id, None) if save: self.save()
def get_active_user_count(time): query = ( Q('date_registered', 'lt', time) & Q('is_registered', 'eq', True) & Q('password', 'ne', None) & Q('merged_by', 'eq', None) & Q('date_confirmed', 'ne', None) & Q('date_disabled', ' eq', None) ) return User.find(query).count()
def revoke_oauth_access(self, external_account, auth, save=True): """Revoke all access to an ``ExternalAccount``. TODO: This should accept node and metadata params in the future, to allow fine-grained revocation of grants. That's not yet been needed, so it's not yet been implemented. """ for node in self.get_nodes_with_oauth_grants(external_account): try: node.get_addon(external_account.provider, deleted=True).deauthorize(auth=auth) except AttributeError: # No associated addon settings despite oauth grant # Remove grant in `for` loop below pass if User.find(Q('external_accounts', 'eq', external_account._id)).count() == 1: # Only this user is using the account, so revoke remote access as well. self.revoke_remote_oauth_access(external_account) for key in self.oauth_grants: self.oauth_grants[key].pop(external_account._id, None) if save: self.save()
def get_unregistered_users(): query = ( Q('is_registered', 'eq', False) ) return User.find(query).count()
def get_unregistered_users(): query = (Q('is_registered', 'eq', False)) return User.find(query).count()
def get_active_user_count(time): query = (Q('date_registered', 'lt', time) & Q('is_registered', 'eq', True) & Q('password', 'ne', None) & Q('merged_by', 'eq', None) & Q('date_confirmed', 'ne', None) & Q('date_disabled', ' eq', None)) return User.find(query).count()
def get_all_user_count(time): query = Q('date_registered', 'lt', time) return User.find(query).count()
def find_user_by_family_name(family_name): user_list = User.find(Q('family_name', 'eq', family_name)) return user_list[0] if user_list.count() == 1 else None
def get_queryset(self): query = (Q('system_tags', 'eq', self.SPAM_TAG)) return User.find(query).sort(self.ordering)
def get_all_user_count(time): query = Q('date_registered', 'lt', time) return User.find(query).count()
def get_queryset(self): query = ( Q('system_tags', 'eq', self.SPAM_TAG) ) return User.find(query).sort(self.ordering)
def find_user_by_family_name(family_name): user_list = User.find(Q('family_name', 'eq', family_name)) return user_list[0] if user_list.count() == 1 else None