MCPcopy
hub / github.com/apache/answer / defaultLoginConfig

Function defaultLoginConfig

internal/cli/config.go:70–92  ·  view source on GitHub ↗
(x *xorm.Engine)

Source from the content-addressed store, hash-verified

68}
69
70func defaultLoginConfig(x *xorm.Engine) (err error) {
71 fmt.Println("set default login config")
72
73 loginSiteInfo := &entity.SiteInfo{
74 Type: constant.SiteTypeLogin,
75 }
76 exist, err := x.Get(loginSiteInfo)
77 if err != nil {
78 return fmt.Errorf("get config failed: %w", err)
79 }
80 if exist {
81 var content map[string]any
82 _ = json.Unmarshal([]byte(loginSiteInfo.Content), &content)
83 content["allow_password_login"] = true
84 dataByte, _ := json.Marshal(content)
85 loginSiteInfo.Content = string(dataByte)
86 _, err = x.ID(loginSiteInfo.ID).Cols("content").Update(loginSiteInfo)
87 if err != nil {
88 return fmt.Errorf("update site info failed: %w", err)
89 }
90 }
91 return nil
92}
93
94func deactivatePlugin(x *xorm.Engine, pluginSlugName string) (err error) {
95 fmt.Printf("try to deactivate plugin: %s\n", pluginSlugName)

Callers 1

SetDefaultConfigFunction · 0.85

Calls 2

UpdateMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected