From 10fcc1452c93e48ee6d8fa781c0658345b30a0c9 Mon Sep 17 00:00:00 2001 From: cuigh Date: Mon, 20 Nov 2017 19:36:46 +0800 Subject: [PATCH] Synchronize with lastest version of auxo --- biz/user.go | 4 ++-- config/app.prd.yml | 3 +++ config/app.yml | 4 +++- main.go | 36 ++++++++++++++++++------------------ views/registry/list.jet | 2 +- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/biz/user.go b/biz/user.go index d923fad..9b8f1c9 100644 --- a/biz/user.go +++ b/biz/user.go @@ -43,7 +43,7 @@ func (b *userBiz) Create(user *model.User, ctxUser web.User) (err error) { user.CreatedAt = time.Now() user.UpdatedAt = user.CreatedAt if user.Type == model.UserTypeInternal { - user.Password, user.Salt, err = password.Get(user.Password) + user.Password, user.Salt, err = password.Generate(user.Password) if err != nil { return } @@ -112,7 +112,7 @@ func (b *userBiz) UpdatePassword(id, oldPwd, newPwd string) (err error) { return } - pwd, salt, err = password.Get(newPwd) + pwd, salt, err = password.Generate(newPwd) if err != nil { return } diff --git a/config/app.prd.yml b/config/app.prd.yml index 69d5743..addfc8a 100644 --- a/config/app.prd.yml +++ b/config/app.prd.yml @@ -1,2 +1,5 @@ +web: + mode: release + swirl: docker_endpoint: tcp://docker-proxy:2375 diff --git a/config/app.yml b/config/app.yml index bca1134..62da79b 100644 --- a/config/app.yml +++ b/config/app.yml @@ -2,7 +2,9 @@ name: swirl banner: false web: - address: ':8001' +# mode: develop + entries: + - address: :8001 authorize: '?' swirl: diff --git a/main.go b/main.go index 3a82caf..10304dc 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,7 @@ func main() { misc.BindOptions() app.Name = "Swirl" - app.Version = "0.6.2" + app.Version = "0.6.3" app.Desc = "A web management UI for Docker, focused on swarm cluster" app.Action = func(ctx *app.Context) { misc.LoadOptions() @@ -40,24 +40,24 @@ func server() *web.Server { panic(fmt.Sprintf("Load setting failed: %v", err)) } - // customize error handler - web.DefaultErrorHandler.OnCode(http.StatusNotFound, func(ctx web.Context, err error) { - if ctx.IsAJAX() { - ctx.Status(http.StatusNotFound).HTML(http.StatusText(http.StatusNotFound)) - } else { - ctx.Render("404", nil) - } - }) - web.DefaultErrorHandler.OnCode(http.StatusForbidden, func(ctx web.Context, err error) { - if ctx.IsAJAX() { - ctx.Status(http.StatusForbidden).HTML("You do not have permission to perform this operation") - } else { - ctx.Render("403", nil) - } - }) - ws := web.Auto() + // customize error handler + ws.ErrorHandler.OnCode(http.StatusNotFound, func(ctx web.Context, err error) { + if ctx.IsAJAX() { + ctx.Status(http.StatusNotFound).HTML(http.StatusText(http.StatusNotFound)) // nolint: gas + } else { + ctx.Status(http.StatusNotFound).Render("404", nil) // nolint: gas + } + }) + ws.ErrorHandler.OnCode(http.StatusForbidden, func(ctx web.Context, err error) { + if ctx.IsAJAX() { + ctx.Status(http.StatusForbidden).HTML("You do not have permission to perform this operation") // nolint: gas + } else { + ctx.Status(http.StatusForbidden).Render("403", nil) // nolint: gas + } + }) + // set render ws.Validator = &valid.Validator{Tag: "valid"} ws.Renderer = jet.New().SetDebug(config.GetBool("debug")). @@ -72,7 +72,7 @@ func server() *web.Server { ws.Use(filter.NewRecover()) // register static handlers - ws.Static("/assets", filepath.Join(filepath.Dir(app.GetPath()), "assets")) + ws.Static("/assets", filepath.Join(filepath.Dir(app.Path()), "assets")) // create biz group form := &auth.Form{ diff --git a/views/registry/list.jet b/views/registry/list.jet index 083b750..280886f 100644 --- a/views/registry/list.jet +++ b/views/registry/list.jet @@ -138,7 +138,7 @@