diff --git a/app/routes.go b/app/routes.go index 29ca9fc..d5e7181 100644 --- a/app/routes.go +++ b/app/routes.go @@ -56,6 +56,7 @@ func (a *App) SetupRoutes() error { e.POST("/signup", handlers.SignupPost(a.db)) e.GET("/home", handlers.Home(a.db), compress) + e.GET("/manage/api-keys", handlers.ManageAPIKeys(), handlers.MiddlewareSession) e.GET("/manage/users", handlers.ManageUsers(), handlers.MiddlewareSession) e.GET("/manage/users/new", handlers.ManageUsers(), handlers.MiddlewareSession) e.POST("/manage/users/create", handlers.CreateUser(), handlers.MiddlewareSession) diff --git a/handlers/manage-apikeys.go b/handlers/manage-apikeys.go new file mode 100644 index 0000000..ffd10b9 --- /dev/null +++ b/handlers/manage-apikeys.go @@ -0,0 +1,39 @@ +// Copyright 2023 wanderer +// SPDX-License-Identifier: AGPL-3.0-only +package handlers + +import ( + "net/http" + + moduser "git.dotya.ml/mirre-mt/pcmt/modules/user" + "github.com/labstack/echo/v4" +) + +func ManageAPIKeys() echo.HandlerFunc { + return func(c echo.Context) error { + addHeaders(c) + u := c.Get("sessUsr").(moduser.User) + + err := c.Render(http.StatusOK, "manage/apikeys.tmpl", + page{ + AppName: setting.AppName(), + AppVer: appver, + Title: "Manage API Keys", + DevelMode: setting.IsDevel(), + Current: "api-keys", + User: u, + }, + ) + if err != nil { + c.Logger().Errorf("error: %q", err) + + return renderErrorPage( + c, + http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError), + err.Error(), + ) + } + + return nil + } +} diff --git a/templates/manage/apikeys.tmpl b/templates/manage/apikeys.tmpl new file mode 100644 index 0000000..f7c2c10 --- /dev/null +++ b/templates/manage/apikeys.tmpl @@ -0,0 +1,49 @@ +{{ template "head.tmpl" . }} + + {{ template "navbar.tmpl" . }} +
+
+

+ Manage Your API keys +

+ {{ if and .Data .Data.flash }} +
+
+

Error: {{.Data.flash}}

+
+ {{- else -}}{{end}} + +
+ +
+

+ Have I Been Pwned? key +

+
+ +
+ +
+
+
+
+ +
+ +
+ +
+

+ Desec.io key +

+
+ +
+ +
+
+
+
+
+
+{{ template "footer.tmpl" . }} diff --git a/templates/navbar.tmpl b/templates/navbar.tmpl index 54ad578..250e154 100644 --- a/templates/navbar.tmpl +++ b/templates/navbar.tmpl @@ -33,6 +33,15 @@ User management +
  • + {{ if pageIs .Current "api-keys" }} + + {{ else }} + + {{ end }} + API keys + +
  • {{end}}
  • About