Synchronize with lastest version of auxo

This commit is contained in:
cuigh 2017-11-20 19:36:46 +08:00
parent ef548fca70
commit 10fcc1452c
5 changed files with 27 additions and 22 deletions

View File

@ -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
}

View File

@ -1,2 +1,5 @@
web:
mode: release
swirl:
docker_endpoint: tcp://docker-proxy:2375

View File

@ -2,7 +2,9 @@ name: swirl
banner: false
web:
address: ':8001'
# mode: develop
entries:
- address: :8001
authorize: '?'
swirl:

36
main.go
View File

@ -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{

View File

@ -138,7 +138,7 @@
</section>
<footer class="modal-card-foot">
<button type="submit" class="button is-primary">{{ i18n("button.submit") }}</button>
<button type="button" class="button dismiss">{{ i18n("field.cancel") }}</button>
<button type="button" class="button dismiss">{{ i18n("button.cancel") }}</button>
</footer>
</form>
</div>