File tree Expand file tree Collapse file tree 10 files changed +34
-0
lines changed
docs/content/doc/advanced Expand file tree Collapse file tree 10 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -649,6 +649,9 @@ PATH =
649
649
; ; Default value for AllowCreateOrganization
650
650
; ; Every new user will have rights set to create organizations depending on this setting
651
651
; DEFAULT_ALLOW_CREATE_ORGANIZATION = true
652
+ ; ; Default value for IsRestricted
653
+ ; ; Every new user will have restricted permissions depending on this setting
654
+ ; DEFAULT_USER_IS_RESTRICTED = true
652
655
; ;
653
656
; ; Either "public", "limited" or "private", default is "public"
654
657
; ; Limited is for signed user only
Original file line number Diff line number Diff line change @@ -499,6 +499,7 @@ relation to port exhaustion.
499
499
- ` HCAPTCHA_SITEKEY ` : ** ""** : Sign up at https://www.hcaptcha.com/ to get a sitekey for hcaptcha.
500
500
- ` DEFAULT_KEEP_EMAIL_PRIVATE ` : ** false** : By default set users to keep their email address private.
501
501
- ` DEFAULT_ALLOW_CREATE_ORGANIZATION ` : ** true** : Allow new users to create organizations by default.
502
+ - ` DEFAULT_USER_IS_RESTRICTED ` : ** false** : Give new users restricted permissions by default
502
503
- ` DEFAULT_ENABLE_DEPENDENCIES ` : ** true** : Enable this to have dependencies enabled by default.
503
504
- ` ALLOW_CROSS_REPOSITORY_DEPENDENCIES ` : ** true** Enable this to allow dependencies on issues from any repository where the user is granted access.
504
505
- ` ENABLE_USER_HEATMAP ` : ** true** : Enable this to display the heatmap on users profiles.
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ ENABLE_CAPTCHA = false
65
65
REQUIRE_SIGNIN_VIEW = false
66
66
DEFAULT_KEEP_EMAIL_PRIVATE = false
67
67
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
68
+ DEFAULT_USER_IS_RESTRICTED = false
68
69
NO_REPLY_ADDRESS = noreply.example.org
69
70
ENABLE_NOTIFY_MAIL = true
70
71
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ ENABLE_CAPTCHA = false
85
85
REQUIRE_SIGNIN_VIEW = false
86
86
DEFAULT_KEEP_EMAIL_PRIVATE = false
87
87
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
88
+ DEFAULT_USER_IS_RESTRICTED = false
88
89
NO_REPLY_ADDRESS = noreply.example.org
89
90
ENABLE_NOTIFY_MAIL = true
90
91
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ ENABLE_CAPTCHA = false
63
63
REQUIRE_SIGNIN_VIEW = false
64
64
DEFAULT_KEEP_EMAIL_PRIVATE = false
65
65
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
66
+ DEFAULT_USER_IS_RESTRICTED = false
66
67
NO_REPLY_ADDRESS = noreply.example.org
67
68
68
69
[picture]
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ ENABLE_CAPTCHA = false
66
66
REQUIRE_SIGNIN_VIEW = false
67
67
DEFAULT_KEEP_EMAIL_PRIVATE = false
68
68
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
69
+ DEFAULT_USER_IS_RESTRICTED = false
69
70
NO_REPLY_ADDRESS = noreply.example.org
70
71
ENABLE_NOTIFY_MAIL = true
71
72
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ ENABLE_CAPTCHA = false
62
62
REQUIRE_SIGNIN_VIEW = false
63
63
DEFAULT_KEEP_EMAIL_PRIVATE = false
64
64
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
65
+ DEFAULT_USER_IS_RESTRICTED = false
65
66
NO_REPLY_ADDRESS = noreply.example.org
66
67
67
68
[picture]
Original file line number Diff line number Diff line change @@ -843,6 +843,7 @@ func CreateUser(u *User) (err error) {
843
843
}
844
844
u .AllowCreateOrganization = setting .Service .DefaultAllowCreateOrganization && ! setting .Admin .DisableRegularOrgCreation
845
845
u .EmailNotificationsPreference = setting .Admin .DefaultEmailNotification
846
+ u .IsRestricted = setting .Service .DefaultUserIsRestricted
846
847
u .MaxRepoCreation = - 1
847
848
u .Theme = setting .UI .DefaultTheme
848
849
Original file line number Diff line number Diff line change @@ -322,6 +322,28 @@ func TestCreateUser(t *testing.T) {
322
322
assert .NoError (t , DeleteUser (user ))
323
323
}
324
324
325
+ func TestCreateUserWithRestrictedUserByDefault (t * testing.T ) {
326
+ user := & User {
327
+ Name : "GiteaBot" ,
328
+ Email : "GiteaBot@gitea.io" ,
329
+ Passwd : ";p['////..-++']" ,
330
+ IsAdmin : false ,
331
+ Theme : setting .UI .DefaultTheme ,
332
+ MustChangePassword : false ,
333
+ }
334
+
335
+ setting .Service .DefaultUserIsRestricted = true
336
+
337
+ assert .NoError (t , CreateUser (user ))
338
+
339
+ savedUser , err := GetUserByEmail (user .Email )
340
+ assert .NoError (t , err )
341
+
342
+ assert .Equal (t , savedUser .IsRestricted , true )
343
+
344
+ assert .NoError (t , DeleteUser (savedUser ))
345
+ }
346
+
325
347
func TestCreateUserInvalidEmail (t * testing.T ) {
326
348
user := & User {
327
349
Name : "GiteaBot" ,
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ var Service struct {
44
44
HcaptchaSitekey string
45
45
DefaultKeepEmailPrivate bool
46
46
DefaultAllowCreateOrganization bool
47
+ DefaultUserIsRestricted bool
47
48
EnableTimetracking bool
48
49
DefaultEnableTimetracking bool
49
50
DefaultEnableDependencies bool
@@ -105,6 +106,7 @@ func newService() {
105
106
Service .HcaptchaSitekey = sec .Key ("HCAPTCHA_SITEKEY" ).MustString ("" )
106
107
Service .DefaultKeepEmailPrivate = sec .Key ("DEFAULT_KEEP_EMAIL_PRIVATE" ).MustBool ()
107
108
Service .DefaultAllowCreateOrganization = sec .Key ("DEFAULT_ALLOW_CREATE_ORGANIZATION" ).MustBool (true )
109
+ Service .DefaultUserIsRestricted = sec .Key ("DEFAULT_USER_IS_RESTRICTED" ).MustBool (false )
108
110
Service .EnableTimetracking = sec .Key ("ENABLE_TIMETRACKING" ).MustBool (true )
109
111
if Service .EnableTimetracking {
110
112
Service .DefaultEnableTimetracking = sec .Key ("DEFAULT_ENABLE_TIMETRACKING" ).MustBool (true )
You can’t perform that action at this time.
0 commit comments