def CheckCanLogin(self, credentials):

        if self._validity == VALIDITY_INVALID:

            raise HydrusExceptions.LoginException(
                'Login script is not valid: ' + self._error_reason)

        for step in self._login_steps:

            try:

                step.TestCredentials(credentials)

            except HydrusExceptions.ValidationException as e:

                raise HydrusExceptions.LoginException(str(e))
    def CheckCanLogin(self, network_context):

        with self._lock:

            if network_context.context_type == CC.NETWORK_CONTEXT_DOMAIN:

                login_network_context = self._GetLoginNetworkContext(
                    network_context)

                if login_network_context is None:

                    raise HydrusExceptions.LoginException(
                        'Could not find a network context to login with!')

                (login_script,
                 credentials) = self._domains_to_login_scripts_and_credentials[
                     login_network_context.context_data]

                login_script.CheckCanLogin(credentials)

            elif network_context.context_type == CC.NETWORK_CONTEXT_HYDRUS:

                service_key = network_context.context_data

                services_manager = self.engine.controller.services_manager

                if not services_manager.ServiceExists(service_key):

                    raise HydrusExceptions.LoginException(
                        'Service does not exist!')

                service = services_manager.GetService(service_key)

                try:

                    service.CheckFunctional(including_account=False)

                except Exception as e:

                    message = 'Service has had a recent error or is otherwise not functional! Specific error was:'
                    message += os.linesep * 2
                    message += HydrusData.ToUnicode(e)
                    message += os.linesep * 2
                    message += 'You might like to try refreshing its account in \'review services\'.'

                    raise HydrusExceptions.LoginException(message)
Example #3
0
 def CheckCanLogin( self ):
     
     with self._lock:
         
         if self._for_login:
             
             raise HydrusExceptions.LoginException( 'Login jobs should not be asked if they can login!' )
             
         else:
             
             return self.engine.login_manager.CheckCanLogin( self._login_network_context )
Example #4
0
    def CheckCanLogin(self, network_context):

        with self._lock:

            if network_context.context_type == CC.NETWORK_CONTEXT_DOMAIN:

                login_network_context = self._GetLoginNetworkContext(
                    network_context)

                if login_network_context is None:

                    raise HydrusExceptions.LoginException(
                        'Could not find a network context to login with!')

                (login_script,
                 credentials) = self._domains_to_login_scripts_and_credentials[
                     login_network_context.context_data]

                login_script.CheckCanLogin(credentials)

            elif network_context.context_type == CC.NETWORK_CONTEXT_HYDRUS:

                service_key = network_context.context_data

                services_manager = self.engine.controller.services_manager

                if not services_manager.ServiceExists(service_key):

                    raise HydrusExceptions.LoginException(
                        'Service does not exist!')

                service = services_manager.GetService(service_key)

                if not service.IsFunctional(ignore_account=True):

                    raise HydrusExceptions.LoginException(
                        'Service has had a recent error or is otherwise not functional! You might like to try refreshing its account in \'review services\'.'
                    )
Example #5
0
 def CheckCanLogin( self, network_context ):
     
     with self._lock:
         
         if network_context.context_type == CC.NETWORK_CONTEXT_DOMAIN:
             
             domain = network_context.context_data
             
             if 'pixiv.net' in domain:
                 
                 if not LEGACY_LOGIN_OK:
                     
                     raise Exception( 'Legacy login broke last time--please either restart the client or contact hydrus dev!' )
                     
                 
                 result = self.engine.controller.Read( 'serialisable_simple', 'pixiv_account' )
                 
                 if result is None:
                     
                     raise HydrusExceptions.DataMissing( 'You need to set up your pixiv credentials in services->manage pixiv account.' )
                     
                 
                 return
                 
             elif 'hentai-foundry.com' in domain:
                 
                 if not LEGACY_LOGIN_OK:
                     
                     raise Exception( 'Legacy login broke last time--please either restart the client or contact hydrus dev!' )
                     
                 
                 return
                 
             
             login_network_context = self._GetLoginNetworkContext( network_context )
             
             if login_network_context is None:
                 
                 raise HydrusExceptions.LoginException( 'Could not find a network context to login with!' )
                 
             
             ( login_script, credentials ) = self._domains_to_login_scripts_and_credentials[ login_network_context.context_data ]
             
             login_script.CheckCanLogin( credentials )
             
         elif network_context.context_type == CC.NETWORK_CONTEXT_HYDRUS:
             
             service_key = network_context.context_data
             
             services_manager = self.engine.controller.services_manager
             
             if not services_manager.ServiceExists( service_key ):
                 
                 raise HydrusExceptions.LoginException( 'Service does not exist!' )
                 
             
             service = services_manager.GetService( service_key )
             
             try:
                 
                 service.CheckFunctional( including_account = False )
                 
             except Exception as e:
                 
                 message = 'Service has had a recent error or is otherwise not functional! Specific error was:'
                 message += os.linesep * 2
                 message += HydrusData.ToUnicode( e )
                 message += os.linesep * 2
                 message += 'You might like to try refreshing its account in \'review services\'.'
                 
                 raise HydrusExceptions.LoginException( message )