diff --git a/pkg/db/user.go b/pkg/db/user.go index 7558aa4..cd273fb 100644 --- a/pkg/db/user.go +++ b/pkg/db/user.go @@ -168,6 +168,9 @@ func (db *DB) UpdateUserSecret(username, secret string) error { } func (db *DB) UpdateUserPassword(username, password string) error { + if password == "" { + return errors.New("empty password") + } u, err := db.GetUser(username) if err != nil { return err diff --git a/pkg/server/handler.go b/pkg/server/handler.go index f575692..7930dda 100644 --- a/pkg/server/handler.go +++ b/pkg/server/handler.go @@ -507,14 +507,14 @@ func userEditHandler(ctx *Context) { Title: "Edit User", BodyTitle: "Edit User", } + u, err := ctx.Srv.DB.GetUserWithoutPassword(ctx.Var("user")) + if err != nil { + ctx.Error(err) + return + } + ctx.Data.Data = u switch ctx.Method() { case "GET": - u, err := ctx.Srv.DB.GetUserWithoutPassword(ctx.Var("user")) - if err != nil { - ctx.Error(err) - return - } - ctx.Data.Data = u ctx.Exec() case "POST": if !ctx.CheckXsrf() {