refactor: "install" page (#39400)

1. remove useless options
2. set AppDataPath instead of repo root path
3. make "disable self-registration" default enabled
4. avoid writing corrupted ini file
5. avoid auto-sign-in the existing admin user
This commit is contained in:
wxiaoguang authored and GitHub committed 2026-09-23 23:14:31 +00:00
1 parent 71065941a9
commit f14cedc4fa
35 files changed
+261 -439

No files matched your search

+11
View File
@@ -9,6 +9,7 @@ import (
"testing"
"gitea.dev/models/unittest"
"gitea.dev/modules/setting"
"gitea.dev/services/contexttest"
"gitea.dev/services/forms"
@@ -59,4 +60,14 @@ func TestFillInstallConfig(t *testing.T) {
assert.NotEmpty(t, cfg.Section("oauth2").Key("JWT_SECRET").String())
assert.Empty(t, cfg.Section("oauth2").Key("JWT_SECRET_URI").String())
})
t.Run("CleanUp", func(t *testing.T) {
tmpFile := t.TempDir() + "/test.ini"
f := &forms.InstallForm{AppName: "foo\x00\r\nbar"}
cfg := fillInstallConfig(ctx, []string{}, f)
err := cfg.SaveTo(tmpFile)
assert.NoError(t, err)
ini, err := setting.NewConfigProviderFromFile(tmpFile)
assert.NoError(t, err)
assert.Equal(t, `foo bar`, ini.Section("").Key("APP_NAME").String())
})
}