-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
add configuration option to restrict users by default #16256
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
techknowlogick
merged 9 commits into
go-gitea:main
from
rjnienaber:add-default-user-is-restricted
Jul 15, 2021
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6ea9563
add configuration option to restrict users by default
rjnienaber 0a27121
default IsRestricted permission only set on sign up
rjnienaber e23a876
fix formatting
rjnienaber 0c05404
Apply suggestions from code review
6543 50cfd70
Merge branch 'main' into add-default-user-is-restricted
6543 607ccd4
ensure newly created user is set to restricted
rjnienaber 32717a8
ensure imports are in the correct order
rjnienaber b718ea4
Merge branch 'main' into add-default-user-is-restricted
techknowlogick b395e4f
Merge branch 'main' into add-default-user-is-restricted
techknowlogick 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import ( | |
"strings" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models" | ||
"code.gitea.io/gitea/modules/setting" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/unknwon/i18n" | ||
|
@@ -33,6 +34,28 @@ func TestSignup(t *testing.T) { | |
MakeRequest(t, req, http.StatusOK) | ||
} | ||
|
||
func TestSignupAsRestricted(t *testing.T) { | ||
defer prepareTestEnv(t)() | ||
|
||
setting.Service.EnableCaptcha = false | ||
setting.Service.DefaultUserIsRestricted = true | ||
|
||
req := NewRequestWithValues(t, "POST", "/user/sign_up", map[string]string{ | ||
"user_name": "restrictedUser", | ||
"email": "[email protected]", | ||
"password": "examplePassword!1", | ||
"retype": "examplePassword!1", | ||
}) | ||
MakeRequest(t, req, http.StatusFound) | ||
|
||
// should be able to view new user's page | ||
req = NewRequest(t, "GET", "/restrictedUser") | ||
MakeRequest(t, req, http.StatusOK) | ||
|
||
user2 := models.AssertExistsAndLoadBean(t, &models.User{Name: "restrictedUser"}).(*models.User) | ||
assert.True(t, user2.IsRestricted) | ||
} | ||
|
||
func TestSignupEmail(t *testing.T) { | ||
defer prepareTestEnv(t)() | ||
|
||
|
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.