From 35448db725d30645987707753d071850de7c19d2 Mon Sep 17 00:00:00 2001 From: ston1th Date: Sat, 27 Oct 2018 23:43:15 +0200 Subject: [PATCH] better style --- pkg/server/helper.go | 14 ++++++-------- pkg/server/templates.go | 6 +++--- templates/userEdit.html | 4 ++-- templates/userTotp.html | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/pkg/server/helper.go b/pkg/server/helper.go index 4b6c475..b8d81f7 100644 --- a/pkg/server/helper.go +++ b/pkg/server/helper.go @@ -15,19 +15,14 @@ const ( ) func duration(duration, mode string) (d time.Duration, err error) { - var m int - m, _ = strconv.Atoi(mode) - switch m { - case 0: - err = errors.New("invalid mode") - return - case 1: + switch mode { + case "1": d, err = time.ParseDuration(duration) if err != nil { err = errors.New("could not parse duration") return } - case 2: + case "2": var t int t, err = strconv.Atoi(duration) if err != nil { @@ -35,6 +30,9 @@ func duration(duration, mode string) (d time.Duration, err error) { return } d = time.Duration(int(day) * t) + default: + err = errors.New("invalid mode") + return } if d < min { diff --git a/pkg/server/templates.go b/pkg/server/templates.go index d2a9129..a110ae2 100644 --- a/pkg/server/templates.go +++ b/pkg/server/templates.go @@ -510,9 +510,9 @@ const (
{{.BodyTitle}} {{if .Data.Secret}} - Disable TOTP + Disable TOTP {{else}} - Enable TOTP + Enable TOTP {{end}}
@@ -658,7 +658,7 @@ const (
- {{.BodyTitle}} + {{.BodyTitle}} - {{.Data.Username}}
diff --git a/templates/userEdit.html b/templates/userEdit.html index 077b4c3..c4ccb22 100644 --- a/templates/userEdit.html +++ b/templates/userEdit.html @@ -6,9 +6,9 @@
{{.BodyTitle}} {{if .Data.Secret}} - Disable TOTP + Disable TOTP {{else}} - Enable TOTP + Enable TOTP {{end}}
diff --git a/templates/userTotp.html b/templates/userTotp.html index dc5b834..cb7db80 100644 --- a/templates/userTotp.html +++ b/templates/userTotp.html @@ -4,7 +4,7 @@
- {{.BodyTitle}} + {{.BodyTitle}} - {{.Data.Username}}