From bbb8995419ab5a8b1ff4fe38d5ed8c81685a1c86 Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Fri, 25 Mar 2022 00:02:54 +0200 Subject: [PATCH] Fix NoAuthorizationError (#19355) --- superset/views/users/api.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/superset/views/users/api.py b/superset/views/users/api.py index 524a382b0679d..8945be9b0c55b 100644 --- a/superset/views/users/api.py +++ b/superset/views/users/api.py @@ -16,6 +16,7 @@ # under the License. from flask import g, Response from flask_appbuilder.api import BaseApi, expose, safe +from flask_jwt_extended.exceptions import NoAuthorizationError from .schemas import UserResponseSchema @@ -51,6 +52,10 @@ def get_me(self) -> Response: 401: $ref: '#/components/responses/401' """ - if g.user is None or g.user.is_anonymous: + try: + if g.user is None or g.user.is_anonymous: + return self.response_401() + except NoAuthorizationError: return self.response_401() + return self.response(200, result=user_response_schema.dump(g.user))