changes + add uploader
Some checks failed
build / build (push) Successful in 27s
release-tag / release-image (push) Has been cancelled

This commit is contained in:
Tijl 2024-08-29 12:31:29 +02:00
parent 7e1c36c966
commit 1383b52f85
Signed by: tijl
GPG Key ID: DAE24BFCD722F053
2 changed files with 34 additions and 30 deletions

View File

@ -32,6 +32,10 @@ func Setup() {
web.RegisterAppSetupFunc(func(a *fiber.App) { web.RegisterAppSetupFunc(func(a *fiber.App) {
a.Get("/app/uploader", func(c *fiber.Ctx) error { a.Get("/app/uploader", func(c *fiber.Ctx) error {
_, err := user.GetSession(c)
if err != nil {
return c.Redirect("/auth?redirect=/app/uploader", http.StatusUnauthorized)
}
data := *web.Common(c) data := *web.Common(c)
data["Title"] = "tmp" data["Title"] = "tmp"
return c.Render("apps/uploader/index", data, "layouts/base") return c.Render("apps/uploader/index", data, "layouts/base")
@ -39,7 +43,7 @@ func Setup() {
a.Get("/app/uploader/:key", func(c *fiber.Ctx) error { a.Get("/app/uploader/:key", func(c *fiber.Ctx) error {
encryptionKey, err := hex.DecodeString(c.Params("key")) encryptionKey, err := hex.DecodeString(c.Params("key"))
if err != nil { if err != nil {
return err return c.Next()
} }
storageKey := hashKey(encryptionKey) storageKey := hashKey(encryptionKey)
@ -57,7 +61,7 @@ func Setup() {
return err return err
} }
if accessCount >= int64(row.MaxVisits) { if accessCount == int64(row.MaxVisits) || accessCount > int64(row.MaxVisits) {
return c.Next() return c.Next()
} }