Been too long since i did anything, can't remember what the hell is in all this....
This commit is contained in:
@@ -25,7 +25,7 @@ func Login(w http.ResponseWriter, r *http.Request) {
|
||||
err := tmpl.ExecuteTemplate(w, "layout", context)
|
||||
if err != nil {
|
||||
log.Println("❌ Template render error:", err)
|
||||
http.Error(w, "Error rendering login page", http.StatusInternalServerError)
|
||||
http.Error(w, "Error rendering login page", http.StatusInternalServerError) // Take hte flash message from licnse server this just does a black page also should be using db ahain see licvense server
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func AdminAccessLogHandler(db *sql.DB) http.HandlerFunc {
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var logs []AdminLogEntry
|
||||
var logs []AdminLogEntry // ToDo should be in models
|
||||
for rows.Next() {
|
||||
var entry AdminLogEntry
|
||||
if err := rows.Scan(&entry.AccessedAt, &entry.UserID, &entry.Path, &entry.IP, &entry.UserAgent); err != nil {
|
||||
|
||||
@@ -193,3 +193,30 @@ func JoinSyndicateWithTokenHandler(db *sql.DB) http.HandlerFunc {
|
||||
http.Redirect(w, r, "/syndicate", http.StatusSeeOther)
|
||||
}
|
||||
}
|
||||
|
||||
func ManageInviteTokensHandler(db *sql.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
userID, ok := helpers.GetCurrentUserID(r)
|
||||
if !ok {
|
||||
helpers.RenderError(w, r, 403)
|
||||
return
|
||||
}
|
||||
|
||||
syndicateID := helpers.Atoi(r.URL.Query().Get("id"))
|
||||
|
||||
if !storage.IsSyndicateManager(db, syndicateID, userID) {
|
||||
helpers.RenderError(w, r, 403)
|
||||
return
|
||||
}
|
||||
|
||||
tokens := storage.GetInviteTokensForSyndicate(db, syndicateID)
|
||||
|
||||
data := BuildTemplateData(db, w, r)
|
||||
context := helpers.TemplateContext(w, r, data)
|
||||
context["Tokens"] = tokens
|
||||
context["SyndicateID"] = syndicateID
|
||||
|
||||
tmpl := helpers.LoadTemplateFiles("invite-links.html", "templates/syndicate/invite_links.html")
|
||||
tmpl.ExecuteTemplate(w, "layout", context)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func BuildTemplateData(db *sql.DB, w http.ResponseWriter, r *http.Request) model
|
||||
|
||||
switch v := session.Values["user_id"].(type) {
|
||||
case int:
|
||||
user = models.GetUserByID(v)
|
||||
user = models.GetUserByID(v) // ToDo should be storage not models
|
||||
case int64:
|
||||
user = models.GetUserByID(int(v))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user