소스 검색

fix: save limit (#119)

* feat: user save limit

* fix: save limit
jeessy2 1 년 전
부모
커밋
efe2e6c51b
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  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()