commit 53946d961463268336a1ed8ad53114076e26b186
parent d440eb914b0808a88d1ca09f09897fb51a2cd662
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sat, 10 Jun 2023 08:10:42 -0700
improve ui
Diffstat:
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go
@@ -217,6 +217,11 @@ func GenerateToken32() string {
return GenerateTokenN(32)
}
+// GenerateToken16 ...
+func GenerateToken16() string {
+ return GenerateTokenN(16)
+}
+
// GenerateToken10 ...
// 0144387f11c617517a41
func GenerateToken10() string {
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -2848,7 +2848,7 @@ func SettingsAPIHandler(c echo.Context) error {
return c.Redirect(http.StatusFound, c.Request().Referer())
}
if formName == "confirm" {
- token := utils.GenerateToken32()
+ token := utils.GenerateToken16()
authUser.ApiKey = token
authUser.DoSave(db)
return c.Redirect(http.StatusFound, c.Request().Referer())
diff --git a/pkg/web/public/views/pages/settings/api.gohtml b/pkg/web/public/views/pages/settings/api.gohtml
@@ -24,7 +24,11 @@
<input type="hidden" name="formName" value="" />
<div class="form-group">
<label>{{ t "API key" . }}</label>
- <input name="api_key" placeholder="API key" value="{{ .Data.APIKey }}" class="form-control" type="text" readonly />
+ {{ if .Data.APIKey }}
+ <div><span style="background-color: black; color: black; font-size: 20px">{{ .Data.APIKey }}</span></div>
+ {{ else }}
+ <div><em>No API key yet</em></div>
+ {{ end }}
</div>
<div class="form-group">
<input type="submit" value="Generate new key" class="btn btn-primary" />