Add Password Algorithm option to install page (#14701)

Add Password Algorithm option to install page

Fix #14674 

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
This commit is contained in:
zeripath 2021-02-16 22:37:20 +00:00 committed by GitHub
parent 66a148e398
commit ad43b119a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 1 deletions

View file

@ -66,6 +66,7 @@ func InstallInit(next http.Handler) http.Handler {
"TmplLoadTimes": func() string {
return time.Since(startTime).String()
},
"PasswordHashAlgorithms": models.AvailableHashAlgorithms,
},
}
ctx.Req = context.WithContext(req, &ctx)
@ -142,6 +143,7 @@ func Install(ctx *context.Context) {
form.DefaultAllowCreateOrganization = setting.Service.DefaultAllowCreateOrganization
form.DefaultEnableTimetracking = setting.Service.DefaultEnableTimetracking
form.NoReplyAddress = setting.Service.NoReplyAddress
form.PasswordAlgorithm = setting.PasswordHashAlgo
middleware.AssignForm(form, ctx.Data)
ctx.HTML(200, tplInstall)
@ -185,6 +187,8 @@ func InstallPost(ctx *context.Context) {
setting.Database.Charset = form.Charset
setting.Database.Path = form.DbPath
setting.PasswordHashAlgo = form.PasswordAlgorithm
if (setting.Database.Type == "sqlite3") &&
len(setting.Database.Path) == 0 {
ctx.Data["Err_DbPath"] = true
@ -380,6 +384,9 @@ func InstallPost(ctx *context.Context) {
return
}
cfg.Section("security").Key("SECRET_KEY").SetValue(secretKey)
if len(form.PasswordAlgorithm) > 0 {
cfg.Section("security").Key("PASSWORD_HASH_ALGO").SetValue(form.PasswordAlgorithm)
}
err = os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
if err != nil {