From 27d09b9acbc12497a845981ddfdb9af1fd15fc8a Mon Sep 17 00:00:00 2001 From: lvdongbing Date: Mon, 11 Jan 2016 20:41:54 -0500 Subject: [PATCH] Fix the issue when trying to show user. Fix the issue when trying to show user and enable admin to show any users. Change-Id: I0f009ef88e8c2349406a53bf04804d3604053346 Closes-Bug: #1533016 --- bilean/db/sqlalchemy/api.py | 2 +- bilean/engine/user.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bilean/db/sqlalchemy/api.py b/bilean/db/sqlalchemy/api.py index aab6e25..5adb993 100644 --- a/bilean/db/sqlalchemy/api.py +++ b/bilean/db/sqlalchemy/api.py @@ -123,7 +123,7 @@ def user_get(context, user_id, show_deleted=False, tenant_safe=True): if user is None or user.deleted_at is not None and not deleted_ok: return None - if tenant_safe and context.tenant_id != user.user_id: + if tenant_safe and context.tenant_id != user.id: return None return user diff --git a/bilean/engine/user.py b/bilean/engine/user.py index cb86254..15e5e94 100644 --- a/bilean/engine/user.py +++ b/bilean/engine/user.py @@ -115,6 +115,8 @@ class User(object): def load(cls, context, user_id=None, user=None, realtime=False, show_deleted=False, tenant_safe=True): '''Retrieve a user from database.''' + if context.is_admin: + tenant_safe = False if user is None: user = db_api.user_get(context, user_id, show_deleted=show_deleted,