Fixed some issues with new db_user-returning credential check.

This commit is contained in:
Sybren A. Stüvel 2016-08-30 16:57:21 +02:00
parent 2c70ceb489
commit 73a62da8da
4 changed files with 10 additions and 7 deletions

View File

@ -125,7 +125,7 @@ class PILLAR_OT_image_share(pillar.PillarOperatorMixin,
self.report({'ERROR'}, 'Please subscribe to the Blender Cloud.') self.report({'ERROR'}, 'Please subscribe to the Blender Cloud.')
self._state = 'QUIT' self._state = 'QUIT'
return return
except pillar.CredentialsNotSyncedError: except pillar.UserNotLoggedInError:
self.log.exception('Error checking/refreshing credentials.') self.log.exception('Error checking/refreshing credentials.')
self.report({'ERROR'}, 'Please log in on Blender ID first.') self.report({'ERROR'}, 'Please log in on Blender ID first.')
self._state = 'QUIT' self._state = 'QUIT'

View File

@ -782,7 +782,8 @@ class PillarOperatorMixin:
async def check_credentials(self, context, required_roles) -> bool: async def check_credentials(self, context, required_roles) -> bool:
"""Checks credentials with Pillar, and if ok returns the user document from Pillar/MongoDB. """Checks credentials with Pillar, and if ok returns the user document from Pillar/MongoDB.
Returns None if the user cannot be found, or if the user is not a Cloud subscriber. :raises UserNotLoggedInError: if the user is not logged in
:raises NotSubscribedToCloudError: if the user does not have any of the required roles
""" """
# self.report({'INFO'}, 'Checking Blender Cloud credentials') # self.report({'INFO'}, 'Checking Blender Cloud credentials')
@ -803,14 +804,16 @@ class PillarOperatorMixin:
except NotSubscribedToCloudError: except NotSubscribedToCloudError:
self._log_subscription_needed() self._log_subscription_needed()
raise raise
except CredentialsNotSyncedError:
self.log.info('Credentials not synced after refreshing, handling as not logged in.')
raise UserNotLoggedInError('Not logged in.')
except UserNotLoggedInError: except UserNotLoggedInError:
self.log.error('User not logged in on Blender ID.') self.log.error('User not logged in on Blender ID.')
raise
else: else:
self.log.info('Credentials refreshed and ok.') self.log.info('Credentials refreshed and ok.')
return db_user return db_user
return None
def _log_subscription_needed(self): def _log_subscription_needed(self):
self.log.warning( self.log.warning(
'Please subscribe to the blender cloud at https://cloud.blender.org/join') 'Please subscribe to the blender cloud at https://cloud.blender.org/join')

View File

@ -289,7 +289,7 @@ class PILLAR_OT_sync(pillar.PillarOperatorMixin,
self.bss_report({'SUBSCRIBE'}, 'Please subscribe to the Blender Cloud.') self.bss_report({'SUBSCRIBE'}, 'Please subscribe to the Blender Cloud.')
self._state = 'QUIT' self._state = 'QUIT'
return return
except pillar.CredentialsNotSyncedError: except pillar.UserNotLoggedInError:
self.log.exception('Error checking/refreshing credentials.') self.log.exception('Error checking/refreshing credentials.')
self.bss_report({'ERROR'}, 'Please log in on Blender ID first.') self.bss_report({'ERROR'}, 'Please log in on Blender ID first.')
self._state = 'QUIT' self._state = 'QUIT'

View File

@ -861,13 +861,13 @@ class PILLAR_OT_switch_hdri(pillar.PillarOperatorMixin,
self.report({'ERROR'}, 'Please subscribe to the Blender Cloud.') self.report({'ERROR'}, 'Please subscribe to the Blender Cloud.')
self._state = 'QUIT' self._state = 'QUIT'
return return
except pillar.CredentialsNotSyncedError: except pillar.UserNotLoggedInError:
self.log.exception('Error checking/refreshing credentials.') self.log.exception('Error checking/refreshing credentials.')
self.report({'ERROR'}, 'Please log in on Blender ID first.') self.report({'ERROR'}, 'Please log in on Blender ID first.')
self._state = 'QUIT' self._state = 'QUIT'
return return
if user_id is None: if not user_id:
raise pillar.UserNotLoggedInError() raise pillar.UserNotLoggedInError()
await self.download_and_replace(context) await self.download_and_replace(context)