superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johnbod...@apache.org
Subject [incubator-superset] branch master updated: [Profile] Fix 5xx when user not found (#7864)
Date Wed, 24 Jul 2019 16:16:23 GMT
This is an automated email from the ASF dual-hosted git repository.

johnbodley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 51b34e4  [Profile] Fix 5xx when user not found (#7864)
51b34e4 is described below

commit 51b34e47511d265ba8f8c2aba2c4b3a807c897a9
Author: Erik Ritter <erik.ritter@airbnb.com>
AuthorDate: Wed Jul 24 09:16:05 2019 -0700

    [Profile] Fix 5xx when user not found (#7864)
---
 superset/views/core.py  | 10 ++++++++--
 superset/views/utils.py | 10 ++--------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/superset/views/core.py b/superset/views/core.py
index 3c652c3..5d3411e 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -2828,7 +2828,7 @@ class Superset(BaseSupersetView):
             return self.dashboard(str(welcome_dashboard_id))
 
         payload = {
-            "user": bootstrap_user_data(),
+            "user": bootstrap_user_data(g.user),
             "common": self.common_bootstrap_payload(),
         }
 
@@ -2846,8 +2846,14 @@ class Superset(BaseSupersetView):
         if not username and g.user:
             username = g.user.username
 
+        user = (
+            db.session.query(ab_models.User).filter_by(username=username).one_or_none()
+        )
+        if not user:
+            abort(404, description=f"User: {username} does not exist.")
+
         payload = {
-            "user": bootstrap_user_data(username, include_perms=True),
+            "user": bootstrap_user_data(user, include_perms=True),
             "common": self.common_bootstrap_payload(),
         }
 
diff --git a/superset/views/utils.py b/superset/views/utils.py
index 97660c5..79b9f90 100644
--- a/superset/views/utils.py
+++ b/superset/views/utils.py
@@ -19,8 +19,7 @@ from collections import defaultdict
 from typing import Any, Dict, List, Optional, Tuple
 from urllib import parse
 
-from flask import g, request
-from flask_appbuilder.security.sqla import models as ab_models
+from flask import request
 import simplejson as json
 
 from superset import app, db, viz
@@ -36,12 +35,7 @@ if not app.config.get("ENABLE_JAVASCRIPT_CONTROLS"):
     FORM_DATA_KEY_BLACKLIST = ["js_tooltip", "js_onclick_href", "js_data_mutator"]
 
 
-def bootstrap_user_data(username=None, include_perms=False):
-    if not username:
-        username = g.user.username
-
-    user = db.session.query(ab_models.User).filter_by(username=username).one()
-
+def bootstrap_user_data(user, include_perms=False):
     payload = {
         "username": user.username,
         "firstName": user.first_name,


Mime
View raw message