update initialization config
initialization user config
This commit is contained in:
parent
b1d5d9858b
commit
ba77e07e36
5 changed files with 6 additions and 3 deletions
|
@ -21,6 +21,7 @@ UserName = admin
|
|||
PWD = zimaboard
|
||||
Email = user@gmail.com
|
||||
Description = description
|
||||
Initialized = false
|
||||
Token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImVyZXJlIiwicGFzc3dvcmQiOiJhZHNmZGYiLCJleHAiOjE2MjQwMDU0ODEsImlzcyI6Imdpbi1ibG9nIn0.JNsCccZuFCwlSMLJg62iOIB2xymk_k7xGa11xhZ07bc
|
||||
|
||||
[zerotier]
|
||||
|
|
|
@ -15,6 +15,7 @@ type UserModel struct {
|
|||
Head string
|
||||
Email string
|
||||
Description string
|
||||
Initialized bool
|
||||
}
|
||||
|
||||
//服务配置
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue