update initialization config

initialization user config
This commit is contained in:
link 2021-10-22 17:57:22 +08:00
parent b1d5d9858b
commit ba77e07e36
5 changed files with 6 additions and 3 deletions

View file

@ -21,6 +21,7 @@ UserName = admin
PWD = zimaboard PWD = zimaboard
Email = user@gmail.com Email = user@gmail.com
Description = description Description = description
Initialized = false
Token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImVyZXJlIiwicGFzc3dvcmQiOiJhZHNmZGYiLCJleHAiOjE2MjQwMDU0ODEsImlzcyI6Imdpbi1ibG9nIn0.JNsCccZuFCwlSMLJg62iOIB2xymk_k7xGa11xhZ07bc Token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImVyZXJlIiwicGFzc3dvcmQiOiJhZHNmZGYiLCJleHAiOjE2MjQwMDU0ODEsImlzcyI6Imdpbi1ibG9nIn0.JNsCccZuFCwlSMLJg62iOIB2xymk_k7xGa11xhZ07bc
[zerotier] [zerotier]

View file

@ -15,6 +15,7 @@ type UserModel struct {
Head string Head string
Email string Email string
Description string Description string
Initialized bool
} }
//服务配置 //服务配置

View file

@ -133,7 +133,7 @@ func PostSetWidgetConfig(c *gin.Context) {
// @Router /guide/check [get] // @Router /guide/check [get]
func GetGuideCheck(c *gin.Context) { func GetGuideCheck(c *gin.Context) {
initUser := false initUser := false
if config.UserInfo.UserName == "admin" && config.UserInfo.PWD == "zimaboard" && version.VersionCompared("0.1.7", types.CURRENTVERSION) { if !config.UserInfo.Initialized {
initUser = true initUser = true
} }
data := make(map[string]interface{}, 1) data := make(map[string]interface{}, 1)

View file

@ -8,7 +8,6 @@ import (
"github.com/IceWhaleTech/CasaOS/pkg/config" "github.com/IceWhaleTech/CasaOS/pkg/config"
jwt2 "github.com/IceWhaleTech/CasaOS/pkg/utils/jwt" jwt2 "github.com/IceWhaleTech/CasaOS/pkg/utils/jwt"
oasis_err2 "github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err" 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/service"
"github.com/IceWhaleTech/CasaOS/types" "github.com/IceWhaleTech/CasaOS/types"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -35,7 +34,7 @@ func Set_Name_Pwd(c *gin.Context) {
username := c.PostForm("username") username := c.PostForm("username")
pwd := c.PostForm("pwd") 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, c.JSON(http.StatusOK,
model.Result{Success: oasis_err2.ERROR, Message: oasis_err2.GetMsg(oasis_err2.INVALID_PARAMS)}) model.Result{Success: oasis_err2.ERROR, Message: oasis_err2.GetMsg(oasis_err2.INVALID_PARAMS)})
return return

View file

@ -21,6 +21,8 @@ func (c *user) SetUser(username, pwd, token, email, desc string) error {
if len(username) > 0 { if len(username) > 0 {
config.Cfg.Section("user").Key("UserName").SetValue(username) config.Cfg.Section("user").Key("UserName").SetValue(username)
config.UserInfo.UserName = username config.UserInfo.UserName = username
config.Cfg.Section("user").Key("Initialized").SetValue("true")
config.UserInfo.Initialized = true
} }
if len(pwd) > 0 { if len(pwd) > 0 {
config.Cfg.Section("user").Key("PWD").SetValue(pwd) config.Cfg.Section("user").Key("PWD").SetValue(pwd)