mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-04 14:46:57 -05:00
Install page - Handle invalid administrator username better (#7060)
* Install page - detect invalid admin username before installing * Also fix #6954
This commit is contained in:
parent
69d81b6569
commit
bd9ed96da5
@ -94,6 +94,10 @@ sqlite_helper = File path for the SQLite3 database.<br>Enter an absolute path if
|
|||||||
err_empty_db_path = The SQLite3 database path cannot be empty.
|
err_empty_db_path = The SQLite3 database path cannot be empty.
|
||||||
no_admin_and_disable_registration = You cannot disable user self-registration without creating an administrator account.
|
no_admin_and_disable_registration = You cannot disable user self-registration without creating an administrator account.
|
||||||
err_empty_admin_password = The administrator password cannot be empty.
|
err_empty_admin_password = The administrator password cannot be empty.
|
||||||
|
err_empty_admin_email = The administrator email cannot be empty.
|
||||||
|
err_admin_name_is_reserved = Administrator Username is invalid, username is reserved
|
||||||
|
err_admin_name_pattern_not_allowed = Administrator Username is invalid, username is pattern is not allowed
|
||||||
|
err_admin_name_is_invalid = Administrator Username is invalid
|
||||||
|
|
||||||
general_title = General Settings
|
general_title = General Settings
|
||||||
app_name = Site Title
|
app_name = Site Title
|
||||||
|
@ -215,8 +215,31 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check admin user creation
|
||||||
|
if len(form.AdminName) > 0 {
|
||||||
|
// Ensure AdminName is valid
|
||||||
|
if err := models.IsUsableUsername(form.AdminName); err != nil {
|
||||||
|
ctx.Data["Err_Admin"] = true
|
||||||
|
ctx.Data["Err_AdminName"] = true
|
||||||
|
if models.IsErrNameReserved(err) {
|
||||||
|
ctx.RenderWithErr(ctx.Tr("install.err_admin_name_is_reserved"), tplInstall, form)
|
||||||
|
return
|
||||||
|
} else if models.IsErrNamePatternNotAllowed(err) {
|
||||||
|
ctx.RenderWithErr(ctx.Tr("install.err_admin_name_pattern_not_allowed"), tplInstall, form)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.RenderWithErr(ctx.Tr("install.err_admin_name_is_invalid"), tplInstall, form)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Check Admin email
|
||||||
|
if len(form.AdminEmail) == 0 {
|
||||||
|
ctx.Data["Err_Admin"] = true
|
||||||
|
ctx.Data["Err_AdminEmail"] = true
|
||||||
|
ctx.RenderWithErr(ctx.Tr("install.err_empty_admin_email"), tplInstall, form)
|
||||||
|
return
|
||||||
|
}
|
||||||
// Check admin password.
|
// Check admin password.
|
||||||
if len(form.AdminName) > 0 && len(form.AdminPasswd) == 0 {
|
if len(form.AdminPasswd) == 0 {
|
||||||
ctx.Data["Err_Admin"] = true
|
ctx.Data["Err_Admin"] = true
|
||||||
ctx.Data["Err_AdminPasswd"] = true
|
ctx.Data["Err_AdminPasswd"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("install.err_empty_admin_password"), tplInstall, form)
|
ctx.RenderWithErr(ctx.Tr("install.err_empty_admin_password"), tplInstall, form)
|
||||||
@ -228,6 +251,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
|
|||||||
ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplInstall, form)
|
ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplInstall, form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if form.AppURL[len(form.AppURL)-1] != '/' {
|
if form.AppURL[len(form.AppURL)-1] != '/' {
|
||||||
form.AppURL += "/"
|
form.AppURL += "/"
|
||||||
|
Loading…
Reference in New Issue
Block a user