feat(install): Add LoginRequired configuration when install

This commit is contained in:
LinkinStars 2023-08-17 10:56:16 +08:00
parent a8d40949d9
commit 16a42301f7
3 changed files with 5 additions and 1 deletions

View File

@ -28,6 +28,7 @@ type Env struct {
AdminName string `json:"name"`
AdminPassword string `json:"password"`
AdminEmail string `json:"email"`
LoginRequired bool `json:"login_required"`
}
func TryToInstallByEnv() (installByEnv bool, err error) {
@ -105,6 +106,7 @@ func initBaseInfo(env *Env) (err error) {
AdminName: env.AdminName,
AdminPassword: env.AdminPassword,
AdminEmail: env.AdminEmail,
LoginRequired: env.LoginRequired,
}
return requestAPI(req, "POST", "/installation/base-info", InitBaseInfo)
}

View File

@ -84,6 +84,7 @@ type InitBaseInfoReq struct {
AdminName string `validate:"required,gt=3,lte=30" json:"name"`
AdminPassword string `validate:"required,gte=8,lte=32" json:"password"`
AdminEmail string `validate:"required,email,gt=0,lte=500" json:"email"`
LoginRequired bool `json:"login_required"`
}
func (r *InitBaseInfoReq) Check() (errFields []*validator.FormErrorField, err error) {

View File

@ -32,6 +32,7 @@ type InitNeedUserInputData struct {
AdminName string
AdminPassword string
AdminEmail string
LoginRequired bool
}
func (m *Mentor) InitDB() error {
@ -159,7 +160,7 @@ func (m *Mentor) initSiteInfoLoginConfig() {
loginConfig := map[string]bool{
"allow_new_registrations": true,
"allow_email_registrations": true,
"login_required": false,
"login_required": m.userData.LoginRequired,
}
loginConfigDataBytes, _ := json.Marshal(loginConfig)
_, m.err = m.engine.Context(m.ctx).Insert(&entity.SiteInfo{