Parcourir la source

fix(create org): Anonymous user can no longer create org, Fixes #2227

Torkel Ödegaard il y a 10 ans
Parent
commit
24bab47f14
2 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 1 1
      pkg/api/frontendsettings.go
  2. 1 1
      pkg/api/org.go

+ 1 - 1
pkg/api/frontendsettings.go

@@ -99,7 +99,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
 		"defaultDatasource": defaultDatasource,
 		"datasources":       datasources,
 		"appSubUrl":         setting.AppSubUrl,
-		"allowOrgCreate":    setting.AllowUserOrgCreate || c.IsGrafanaAdmin,
+		"allowOrgCreate":    (setting.AllowUserOrgCreate && c.IsSignedIn) || c.IsGrafanaAdmin,
 		"buildInfo": map[string]interface{}{
 			"version":    setting.BuildVersion,
 			"commit":     setting.BuildCommit,

+ 1 - 1
pkg/api/org.go

@@ -40,7 +40,7 @@ func getOrgHelper(orgId int64) Response {
 
 // POST /api/orgs
 func CreateOrg(c *middleware.Context, cmd m.CreateOrgCommand) Response {
-	if !setting.AllowUserOrgCreate && !c.IsGrafanaAdmin {
+	if !c.IsSignedIn || (!setting.AllowUserOrgCreate && !c.IsGrafanaAdmin) {
 		return ApiError(401, "Access denied", nil)
 	}