diff --git a/main.go b/main.go index 1c6b2a3..fe3ab5f 100644 --- a/main.go +++ b/main.go @@ -143,12 +143,13 @@ func (r *Router) index(w http.ResponseWriter, req *http.Request) { if hasUserId { row := r.db.QueryRow(` UPDATE users SET last_seen_timestamp = strftime('%s', 'now') WHERE buck_id = ?1 - RETURNING name_num, discord_id, added_to_mailinglist + RETURNING name_num, discord_id, added_to_mailinglist, is_admin `, userId) var nameNum string var discordId sql.NullString var isOnMailingList bool - err := row.Scan(&nameNum, &discordId, &isOnMailingList) + var isAdmin bool + err := row.Scan(&nameNum, &discordId, &isOnMailingList, &isAdmin) if err != nil { log.Println("Failed to get user:", err, userId) http.Redirect(w, req, "/signout", http.StatusTemporaryRedirect) @@ -190,6 +191,7 @@ func (r *Router) index(w http.ResponseWriter, req *http.Request) { "canAttend": canAttend, "hasLinkedDiscord": discordId.Valid, "isOnMailingList": isOnMailingList, + "isAdmin": isAdmin, }) if err != nil { log.Println("Failed to render template:", err) diff --git a/migrations/seed.sql b/migrations/seed.sql index 6d162a4..3c0decb 100644 --- a/migrations/seed.sql +++ b/migrations/seed.sql @@ -1,3 +1,9 @@ +BEGIN; +INSERT OR REPLACE INTO users +(buck_id, discord_id, display_name, name_num, last_seen_timestamp, last_attended_timestamp, added_to_mailinglist, student, alum, employee, faculty, is_admin) +VALUES +(500123456, NULL, 'Brutus Buckeye', 'buckeye.1', NULL, NULL, 1,1,0,0,0,1); + INSERT OR REPLACE INTO users (buck_id, discord_id, display_name, name_num, last_seen_timestamp, last_attended_timestamp, added_to_mailinglist, student, alum, employee, faculty) VALUES @@ -1001,3 +1007,4 @@ VALUES (525119038,NULL,'Rickie Cheetam','cheetam.4576',1684794159,1652435455,0,1,0,1,0), (506436165,6536698969953349102,'Brook Andreu','andreu.3878',1638836524,1651666692,0,1,1,1,0), (533335732,NULL,'Gale Biggins','biggins.3347',1655272710,1663024697,1,1,0,0,1); +COMMIT; diff --git a/templates/index.html.tpl b/templates/index.html.tpl index c4845b2..5e0b087 100644 --- a/templates/index.html.tpl +++ b/templates/index.html.tpl @@ -78,5 +78,20 @@ + {{ if .isAdmin }} +
+
Admin Dashboard
+
+

+ You are an admin. Click + here to go to the admin page. +

+
+
+ {{ end }} {{ end }}