Browse Source

fix: save limit (#119)

* feat: user save limit

* fix: save limit
jeessy2 1 năm trước cách đây
mục cha
commit
efe2e6c51b
1 tập tin đã thay đổi với 7 bổ sung0 xóa
  1. 7 0
      web/save.go

+ 7 - 0
web/save.go

@@ -23,6 +23,13 @@ func Save(writer http.ResponseWriter, request *http.Request) {
 	oldConf, _ := entity.GetConfigCache()
 	conf := &entity.Config{}
 
+	if oldConf.Password == "" {
+		if time.Since(startTime) > saveLimit {
+			writer.Write([]byte(fmt.Sprintf("需在 %s 之前完成用户名密码设置,请重启backup-x", startTime.Add(saveLimit).Format("2006-01-02 15:04:05"))))
+			return
+		}
+	}
+
 	conf.EncryptKey = oldConf.EncryptKey
 	if conf.EncryptKey == "" {
 		encryptKey, err := util.GenerateEncryptKey()