eba19988788a49d5715af0ff728b19f12ee30a69
braney
  Fri Mar 28 12:22:23 2025 -0700
require users be logged in to edit collections

diff --git src/hg/hgCollection/hgCollection.c src/hg/hgCollection/hgCollection.c
index 3cef96f7f06..649bf70d1cc 100644
--- src/hg/hgCollection/hgCollection.c
+++ src/hg/hgCollection/hgCollection.c
@@ -7,30 +7,31 @@
 #include "trackHub.h"
 #include "trashDir.h"
 #include "hubConnect.h"
 #include "hui.h"
 #include "grp.h"
 #include "cheapcgi.h"
 #include "jsHelper.h"
 #include "web.h"
 #include "knetUdc.h"
 #include "api.h"
 #include "genbank.h"
 #include "htmshell.h"
 #include "jsonParse.h"
 #include "customComposite.h"
 #include "stdlib.h"
+#include "wikiLink.h"
 
 /* Tool tips */
 #define COLLECTION_TITLE  "Double-click to edit name and color"
 #define FOLDER_TITLE      "Click to open node"
 #define TRACK_TITLE       "Press Green Plus to add track to collection"
 
 /* Global Variables */
 struct hash *oldVars = NULL;	/* The cart before new cgi stuff added. */
 // Null terminated list of CGI Variables we don't want to save permanently:
 char *excludeVars[] = {"Submit", "submit", "cmd", "track", "collection", "jsonp", NULL,};
 
 struct track
 {
 struct track *next;
 struct track *trackList;
@@ -989,30 +990,35 @@
 
 outHubHeader(f, db);
 struct sqlConnection *conn = NULL;
 if (!trackHubDatabase(db))
     conn = hAllocConn(db);
 saveTrackName(newTdb, hubName, NULL);
 printTrackDbListToHub(db, conn, f, hubName, trackList, collectionName, newTdb,  0, 0);
 
 hFreeConn(&conn);
 fclose(f);
 }
 
 static void doMiddle(struct cart *cart)
 /* Set up globals and make web page */
 {
+char *userName = (loginSystemEnabled() || wikiLinkEnabled()) ? wikiLinkUserName() : NULL;
+
+if (userName == NULL)
+    errAbort("You must be logged in to edit collections. Visit our <A HREF=\"hgLogin?hgLogin.do.displayLoginPage=1\">login page.</A?");
+
 char *db;
 char *genome;
 getDbAndGenome(cart, &db, &genome, oldVars);
 initGenbankTableNames(db);
 int timeout = cartUsualInt(cart, "udcTimeout", 300);
 if (udcCacheTimeout() < timeout)
     udcSetCacheTimeout(timeout);
 knetUdcInstall();
 
 struct trackDb *trackList;
 struct grp *groupList;
 cartTrackDbInit(cart, &trackList, &groupList, TRUE);
 pruneTrackList(&trackList, &groupList);
 
 struct trackDb *superList = addSupers(trackList);