Ejemplo n.º 1
0
    def verify_account(self, account):
        """
        Verify the credentials provided by logging in.
        Verify the account configuration -- specifically checks for the presence
        of the 'All Mail' folder.

        Raises
        ------
        An inbox.crispin.GmailSettingError if the 'All Mail' folder is
        not present and is required (account.sync_email == True).

        """
        try:
            # Verify login.
            conn = self.connect_account(account)
            # Verify configuration.
            client = GmailCrispinClient(account.id,
                                        provider_info('gmail'),
                                        account.email_address,
                                        conn,
                                        readonly=True)
            client.sync_folders()
            conn.logout()
        except ImapSupportDisabledError:
            if account.sync_email:
                raise

        # Reset the sync_state to 'running' on a successful re-auth.
        # Necessary for API requests to proceed and an account modify delta to
        # be returned to delta/ streaming clients.
        # NOTE: Setting this does not restart the sync. Sync scheduling occurs
        # via the sync_should_run bit (set to True in update_account() above).
        account.sync_state = ('running'
                              if account.sync_state else account.sync_state)
        return True
Ejemplo n.º 2
0
    def verify_account(self, account):
        """
        Verify the credentials provided by logging in.
        Verify the account configuration -- specifically checks for the presence
        of the 'All Mail' folder.

        Raises
        ------
        An inbox.crispin.GmailSettingError if the 'All Mail' folder is
        not present and is required (account.sync_email == True).

        """
        try:
            # Verify login.
            conn = self.connect_account(account)
            # Verify configuration.
            client = GmailCrispinClient(account.id,
                                        provider_info('gmail'),
                                        account.email_address,
                                        conn,
                                        readonly=True)
            client.sync_folders()
            conn.logout()
        except ImapSupportDisabledError:
            if account.sync_email:
                raise

        # Reset the sync_state to 'running' on a successful re-auth.
        # Necessary for API requests to proceed and an account modify delta to
        # be returned to delta/ streaming clients.
        account.sync_state = ('running' if account.sync_state in
                              ('running', 'invalid') else account.sync_state)
        return True
Ejemplo n.º 3
0
 def verify_config(self, account):
     """Verifies configuration, specifically presence of 'All Mail' folder.
        Will raise an inbox.crispin.GmailSettingError if not present.
     """
     conn = self.connect_account(account)
     # make a crispin client and check the folders
     client = GmailCrispinClient(account.id,
                                 provider_info('gmail'),
                                 account.email_address,
                                 conn,
                                 readonly=True)
     client.sync_folders()
     conn.logout()
     return True
Ejemplo n.º 4
0
 def verify_config(self, account):
     """Verifies configuration, specifically presence of 'All Mail' folder.
        Will raise an inbox.crispin.GmailSettingError if not present.
     """
     conn = self.connect_account(account)
     # make a crispin client and check the folders
     client = GmailCrispinClient(account.id,
                                 provider_info('gmail'),
                                 account.email_address,
                                 conn,
                                 readonly=True)
     client.sync_folders()
     conn.logout()
     return True