summaryrefslogtreecommitdiffstats
path: root/routers/install
diff options
context:
space:
mode:
authorJimmy Praet <jimmy.praet@telenet.be>2022-04-29 21:38:11 +0200
committerGitHub <noreply@github.com>2022-04-29 15:38:11 -0400
commit5aebc4f000354d9fa448033445c6f313f4c6ab08 (patch)
treec081c5eff890a454b4c4c3a6aa9d1329eba09052 /routers/install
parent219c87e7d889f5c62097968e5ec8ad04f244cd3c (diff)
downloadgitea-5aebc4f000354d9fa448033445c6f313f4c6ab08.tar.gz
gitea-5aebc4f000354d9fa448033445c6f313f4c6ab08.zip
Respect DefaultUserIsRestricted system default when creating new user (#19310)
* Apply DefaultUserIsRestricted in CreateUser * Enforce system defaults in CreateUser Allow for overwrites with CreateUserOverwriteOptions * Fix compilation errors * Add "restricted" option to create user command * Add "restricted" option to create user admin api * Respect default setting.Service.RegisterEmailConfirm and setting.Service.RegisterManualConfirm where needed * Revert "Respect default setting.Service.RegisterEmailConfirm and setting.Service.RegisterManualConfirm where needed" This reverts commit ee95d3e8dc9e9fff4fa66a5111e4d3930280e033.
Diffstat (limited to 'routers/install')
-rw-r--r--routers/install/install.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/routers/install/install.go b/routers/install/install.go
index ec1719439f..9d28bc1571 100644
--- a/routers/install/install.go
+++ b/routers/install/install.go
@@ -499,13 +499,17 @@ func SubmitInstall(ctx *context.Context) {
// Create admin account
if len(form.AdminName) > 0 {
u := &user_model.User{
- Name: form.AdminName,
- Email: form.AdminEmail,
- Passwd: form.AdminPasswd,
- IsAdmin: true,
- IsActive: true,
+ Name: form.AdminName,
+ Email: form.AdminEmail,
+ Passwd: form.AdminPasswd,
+ IsAdmin: true,
}
- if err = user_model.CreateUser(u); err != nil {
+ overwriteDefault := &user_model.CreateUserOverwriteOptions{
+ IsRestricted: util.OptionalBoolFalse,
+ IsActive: util.OptionalBoolTrue,
+ }
+
+ if err = user_model.CreateUser(u, overwriteDefault); err != nil {
if !user_model.IsErrUserAlreadyExist(err) {
setting.InstallLock = false
ctx.Data["Err_AdminName"] = true