Show which Blender ID instance is communicated with in the addon prefs
This is only shown if it was overridden by setting the BLENDER_ID_ENDPOINT environment variable. It makes Cloud development a bit easier when it's explicit to which Blender ID (local dev or real one) we're talking.
This commit is contained in:
parent
fa7f7ca3ba
commit
7a513da9d8
|
@ -6,6 +6,8 @@
|
|||
- API change: `blender_id.get_subclient_user_id()` now returns `''` instead of `None` when the user
|
||||
is not logged in.
|
||||
- Log which Blender ID instance is communicated with.
|
||||
- Show which Blender ID instance is communicated with in the addon preferences,
|
||||
if it was overridden by setting the BLENDER_ID_ENDPOINT environment variable.
|
||||
|
||||
|
||||
# Version 1.5 (released 2018-07-03)
|
||||
|
|
|
@ -239,16 +239,20 @@ class BlenderIdPreferences(AddonPreferences):
|
|||
else:
|
||||
exp_str = 'within seconds'
|
||||
|
||||
if time_left.days < 14:
|
||||
layout.label(text='You are logged in as %s.' % active_profile.username,
|
||||
icon='WORLD_DATA')
|
||||
layout.label(text='Your token will expire %s. Please log out and log in again '
|
||||
'to refresh it.' % exp_str, icon='PREVIEW_RANGE')
|
||||
endpoint = communication.blender_id_endpoint()
|
||||
if endpoint == communication.BLENDER_ID_ENDPOINT:
|
||||
msg = 'You are logged in as %s.' % active_profile.username
|
||||
else:
|
||||
layout.label(
|
||||
text='You are logged in as %s. Your authentication token expires %s.'
|
||||
% (active_profile.username, exp_str),
|
||||
icon='WORLD_DATA')
|
||||
msg = 'You are logged in as %s at %s.' % (active_profile.username, endpoint)
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text=msg, icon='WORLD_DATA')
|
||||
if time_left.days < 14:
|
||||
col.label(text='Your token will expire %s. Please log out and log in again '
|
||||
'to refresh it.' % exp_str, icon='PREVIEW_RANGE')
|
||||
else:
|
||||
col.label(text='Your authentication token expires %s.' % exp_str,
|
||||
icon='BLANK1')
|
||||
|
||||
row = layout.row().split(factor=0.8)
|
||||
row.operator('blender_id.logout')
|
||||
|
@ -263,7 +267,7 @@ class BlenderIdPreferences(AddonPreferences):
|
|||
class BlenderIdMixin:
|
||||
@staticmethod
|
||||
def addon_prefs(context):
|
||||
preferences = context.preferences.addons[__name__].preferences
|
||||
preferences = context.user_preferences.addons[__name__].preferences
|
||||
preferences.reset_messages()
|
||||
return preferences
|
||||
|
||||
|
@ -352,7 +356,7 @@ def register():
|
|||
bpy.utils.register_class(BlenderIdPreferences)
|
||||
bpy.utils.register_class(BlenderIdValidate)
|
||||
|
||||
preferences = bpy.context.preferences.addons[__name__].preferences
|
||||
preferences = bpy.context.user_preferences.addons[__name__].preferences
|
||||
preferences.reset_messages()
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ import typing
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Can be overridden by setting the environment variable BLENDER_ID_ENDPOINT.
|
||||
BLENDER_ID_ENDPOINT = 'https://www.blender.org/id/'
|
||||
|
||||
|
||||
class BlenderIdCommError(RuntimeError):
|
||||
"""Raised when there was an error communicating with Blender ID"""
|
||||
|
@ -59,7 +62,7 @@ def blender_id_endpoint(endpoint_path=None):
|
|||
if base_url:
|
||||
log.warning('Using overridden Blender ID url %s', base_url)
|
||||
else:
|
||||
base_url = 'https://www.blender.org/id/'
|
||||
base_url = BLENDER_ID_ENDPOINT
|
||||
log.info('Using standard Blender ID url %s', base_url)
|
||||
|
||||
# urljoin() is None-safe for the 2nd parameter.
|
||||
|
|
Loading…
Reference in New Issue