diff --git a/handlers/messages.go b/handlers/messages.go index 416caf3..c7bf9dd 100644 --- a/handlers/messages.go +++ b/handlers/messages.go @@ -47,6 +47,7 @@ func MessagesInboxHandler(db *sql.DB) http.HandlerFunc { tmpl := templateHelpers.LoadTemplateFiles("messages.html", "templates/account/messages/index.html") if err := tmpl.ExecuteTemplate(w, "layout", context); err != nil { + // ToDo: Make this load all error pages without defining explictly. templateHelpers.RenderError(w, r, 500) } } diff --git a/storage/db.go b/storage/db.go index 941a2f4..c05be75 100644 --- a/storage/db.go +++ b/storage/db.go @@ -15,7 +15,7 @@ var db *sql.DB func InitDB(filepath string) *sql.DB { var err error cfg := config.Get() - db, err := sql.Open("sqlite", filepath) + db, err = sql.Open("sqlite", filepath) if err != nil { log.Fatal("❌ Failed to open DB:", err) } @@ -29,6 +29,7 @@ func InitDB(filepath string) *sql.DB { SchemaUsersMessages, SchemaUsersNotifications, SchemaAuditLog, + SchemaAuditLogin, SchemaLogTicketMatching, SchemaAdminAccessLog, SchemaNewAuditLog, diff --git a/storage/schema.go b/storage/schema.go index 4f841f7..49aed25 100644 --- a/storage/schema.go +++ b/storage/schema.go @@ -175,6 +175,16 @@ CREATE TABLE IF NOT EXISTS audit_log ( timestamp DATETIME DEFAULT CURRENT_TIMESTAMP );` +const SchemaAuditLogin = ` + CREATE TABLE IF NOT EXISTS audit_login ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + username TEXT, + success BOOLEAN, + ip TEXT, + user_agent TEXT, + timestamp DATETIME DEFAULT CURRENT_TIMESTAMP + );` + const SchemaSyndicates = ` CREATE TABLE IF NOT EXISTS syndicates ( id INTEGER PRIMARY KEY AUTOINCREMENT,