Skip to content

CasaOS - A simple, easy-to-use, elegant open-source Personal Cloud system.

update initialization config

linkba77e07e3686
diff --git a/conf/conf.ini.sample b/conf/conf.ini.sample
index 1dc9c76..35ab707 100644
--- a/conf/conf.ini.sample
+++ b/conf/conf.ini.sample
@@ -21,6 +21,7 @@ UserName = admin
PWD = zimaboard
Description = description
+Initialized = false
Token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImVyZXJlIiwicGFzc3dvcmQiOiJhZHNmZGYiLCJleHAiOjE2MjQwMDU0ODEsImlzcyI6Imdpbi1ibG9nIn0.JNsCccZuFCwlSMLJg62iOIB2xymk_k7xGa11xhZ07bc
[zerotier]
diff --git a/model/sys_common.go b/model/sys_common.go
index fb61c2f..a1e2789 100644
--- a/model/sys_common.go
+++ b/model/sys_common.go
@@ -15,6 +15,7 @@ type UserModel struct {
Head string
Email string
Description string
+ Initialized bool
}
//服务配置
diff --git a/route/v1/system.go b/route/v1/system.go
index fecd05b..38ab791 100644
--- a/route/v1/system.go
+++ b/route/v1/system.go
@@ -133,7 +133,7 @@ func PostSetWidgetConfig(c *gin.Context) {
// @Router /guide/check [get]
func GetGuideCheck(c *gin.Context) {
initUser := false
- if config.UserInfo.UserName == "admin" && config.UserInfo.PWD == "zimaboard" && version.VersionCompared("0.1.7", types.CURRENTVERSION) {
+ if !config.UserInfo.Initialized {
initUser = true
}
data := make(map[string]interface{}, 1)
diff --git a/route/v1/user.go b/route/v1/user.go
index 99b88c3..9d788d1 100644
--- a/route/v1/user.go
+++ b/route/v1/user.go
@@ -8,7 +8,6 @@ import (
"github.com/IceWhaleTech/CasaOS/pkg/config"
jwt2 "github.com/IceWhaleTech/CasaOS/pkg/utils/jwt"
oasis_err2 "github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
- "github.com/IceWhaleTech/CasaOS/pkg/utils/version"
"github.com/IceWhaleTech/CasaOS/service"
"github.com/IceWhaleTech/CasaOS/types"
"github.com/gin-gonic/gin"
@@ -35,7 +34,7 @@ func Set_Name_Pwd(c *gin.Context) {
username := c.PostForm("username")
pwd := c.PostForm("pwd")
//老用户名是否存在即新用户名和密码的验证
- if (!(config.UserInfo.UserName == "admin" && config.UserInfo.PWD == "zimaboard" && version.VersionCompared("0.1.7", types.CURRENTVERSION)) && len(config.UserInfo.UserName) > 0) || len(username) == 0 || len(pwd) == 0 {
+ if config.UserInfo.Initialized || len(username) == 0 || len(pwd) == 0 {
c.JSON(http.StatusOK,
model.Result{Success: oasis_err2.ERROR, Message: oasis_err2.GetMsg(oasis_err2.INVALID_PARAMS)})
return
diff --git a/service/user.go b/service/user.go
index 21ba661..c8c49b4 100644
--- a/service/user.go
+++ b/service/user.go
@@ -21,6 +21,8 @@ func (c *user) SetUser(username, pwd, token, email, desc string) error {
if len(username) > 0 {
config.Cfg.Section("user").Key("UserName").SetValue(username)
config.UserInfo.UserName = username
+ config.Cfg.Section("user").Key("Initialized").SetValue("true")
+ config.UserInfo.Initialized = true
}
if len(pwd) > 0 {
config.Cfg.Section("user").Key("PWD").SetValue(pwd)