The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
fix: check email in update before validing for sso (#63915)
Edward Pagetc59e9de09000
diff --git a/src/metabase/users/api.clj b/src/metabase/users/api.cljindex db8cca5af37..50f361f4327 100644--- a/src/metabase/users/api.clj+++ b/src/metabase/users/api.clj@@ -444,7 +444,8 @@;; only allow updates if the specified account is active(api/let-404 [user-before-update (fetch-user :id id, :is_active true)];; Google/LDAP non-admin users can't change their email to prevent account hijacking- (api/check-403 (valid-email-update? user-before-update email))+ (when (contains? body :email)+ (api/check-403 (valid-email-update? user-before-update email)));; SSO users (JWT, SAML, LDAP, Google) can't change their first/last names(when (contains? body :first_name)(api/checkp (valid-name-update? user-before-update :first_name first_name)diff --git a/test/metabase/users/api_test.clj b/test/metabase/users/api_test.cljindex 47b16bb3155..f5dfc52aa03 100644--- a/test/metabase/users/api_test.clj+++ b/test/metabase/users/api_test.clj@@ -1081,6 +1081,26 @@(client/client creds :put 403 (format "user/%d" (u/the-id user)){:email "[email protected]"}))))))))+(deftest update-permissions-test-2+ (testing "PUT /api/user/:id"+ (testing "Google auth users can change their locale"+ (mt/with-temp [:model/User user {:email "[email protected]"+ :password "def123"+ :sso_source "google"}]+ (let [creds {:username "[email protected]"+ :password "def123"}]+ (client/client creds :put 200 (format "user/%d" (u/the-id user))+ {:locale "id"}))))++ (testing "LDAP users can change their locale"+ (mt/with-temp [:model/User user {:email "[email protected]"+ :password "def123"+ :sso_source "ldap"}]+ (let [creds {:username "[email protected]"+ :password "def123"}]+ (client/client creds :put 200 (format "user/%d" (u/the-id user))+ {:locale "id"}))))))+(defn- do-with-preserved-rasta-personal-collection-name! [thunk](let [{collection-name :name, :keys [slug id]} (collection/user->personal-collection (mt/user->id :rasta))](mt/with-temp-vals-in-db :model/Collection id {:name collection-name, :slug slug}