-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add configuration to restrict allowed user visibility modes #16271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zeripath
merged 15 commits into
go-gitea:main
from
6543-forks:settings-lowest-allowed-user-visiblity
Jun 27, 2021
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
40ba7d7
restructure CreateUser
6543 8a9589d
Service.AllowedUserVisibilityModes
6543 0bc0c97
validate user on update too
6543 6b49fc4
Apply to UI
6543 365ab6f
docu
6543 e2dd97e
init AllowedUserVisibilityModesMap for unit-tests if needed
6543 aad443d
fix lint
6543 4493a79
move from map too bool slice
6543 139433e
lint
6543 5882b72
dedub code
6543 ab9114a
init AllowedUserVisibilityModesSlice for unit-tests who need it
6543 580f4a3
Update modules/setting/service.go
6543 023ed7e
set default value at definition
6543 da94919
Merge branch 'main' into settings-lowest-allowed-user-visiblity
6543 bec0b55
Merge branch 'main' into settings-lowest-allowed-user-visiblity
zeripath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
"testing" | ||
|
||
"code.gitea.io/gitea/modules/setting" | ||
"code.gitea.io/gitea/modules/structs" | ||
"code.gitea.io/gitea/modules/util" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
@@ -189,6 +190,7 @@ func TestDeleteUser(t *testing.T) { | |
|
||
func TestEmailNotificationPreferences(t *testing.T) { | ||
assert.NoError(t, PrepareTestDatabase()) | ||
|
||
for _, test := range []struct { | ||
expected string | ||
userID int64 | ||
|
@@ -467,3 +469,23 @@ ssh-dss AAAAB3NzaC1kc3MAAACBAOChCC7lf6Uo9n7BmZ6M8St19PZf4Tn59NriyboW2x/DZuYAz3ib | |
} | ||
} | ||
} | ||
|
||
func TestUpdateUser(t *testing.T) { | ||
assert.NoError(t, PrepareTestDatabase()) | ||
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) | ||
|
||
user.KeepActivityPrivate = true | ||
assert.NoError(t, UpdateUser(user)) | ||
user = AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) | ||
assert.True(t, user.KeepActivityPrivate) | ||
|
||
setting.Service.AllowedUserVisibilityModesSlice = []bool{true, false, false} | ||
user.KeepActivityPrivate = false | ||
user.Visibility = structs.VisibleTypePrivate | ||
assert.Error(t, UpdateUser(user)) | ||
user = AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) | ||
assert.True(t, user.KeepActivityPrivate) | ||
|
||
user.Email = "no [email protected]" | ||
assert.Error(t, UpdateUser(user)) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.