-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add option to change username to the admin panel #14229
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
Merged
Changes from 10 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
2c5edbd
Add option to change username to the admin panel
Bwko 96b4ed2
Merge branch 'master' into change_username
techknowlogick 571d6e9
Merge branch 'master' into change_username
techknowlogick 8f44051
Merge branch 'master' into change_username
techknowlogick 93076c0
Update year
techknowlogick de9c5ab
Merge branch 'master' into change_username
techknowlogick 47aa7a5
Merge branch 'master' into change_username
zeripath d105721
Merge branch 'master' into Bwko/change_username
6543 16bc2b9
fix merge conflict relicts
6543 a8a44d0
fix
6543 f6926ae
Same limit on AdminEditUserForm as in AdminCreateUserForm
6543 e1db950
Impruve ChangeUserName
6543 e93e3ec
re-use HandleUsernameChange
6543 3524d0c
fix redirect url & return error if non local acount
6543 0bb5d69
Merge branch 'master' into Bwko/change_username
6543 d259210
fix lint
6543 cdf3ca8
Merge branch 'master' into Bwko/change_username
6543 ed4573b
it's 2021 😵
6543 f58fe15
Merge branch 'master' into Bwko/change_username
6543 f456600
Merge branch 'master' into Bwko/change_username
6543 a503f9f
Merge branch 'master' into Bwko/change_username
6543 f6de287
Merge branch 'master' into Bwko/change_username
6543 8f72728
Merge branch 'master' into Bwko/change_username
6543 dd9a3be
Merge branch 'master' into Bwko/change_username
6543 8360ac7
Merge branch 'master' into Bwko/change_username
6543 cef44d7
Merge branch 'master' into Bwko/change_username
6543 bd0b4b9
Merge branch 'master' into Bwko/change_username
6543 b622cba
Merge branch 'master' into Bwko/change_username
6543 cd2f5aa
Update integrations/admin_user_test.go
6543 951cf37
Merge branch 'master' into Bwko/change_username
6543 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2019 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package integrations | ||
|
||
import ( | ||
"net/http" | ||
"strconv" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models" | ||
"github.com/stretchr/testify/assert" | ||
6543 marked this conversation as resolved.
Show resolved
Hide resolved
6543 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
func TestAdminViewUsers(t *testing.T) { | ||
prepareTestEnv(t) | ||
|
||
session := loginUser(t, "user1") | ||
req := NewRequest(t, "GET", "/admin/users") | ||
session.MakeRequest(t, req, http.StatusOK) | ||
|
||
session = loginUser(t, "user2") | ||
req = NewRequest(t, "GET", "/admin/users") | ||
session.MakeRequest(t, req, http.StatusForbidden) | ||
} | ||
|
||
func TestAdminViewUser(t *testing.T) { | ||
prepareTestEnv(t) | ||
|
||
session := loginUser(t, "user1") | ||
req := NewRequest(t, "GET", "/admin/users/1") | ||
session.MakeRequest(t, req, http.StatusOK) | ||
|
||
session = loginUser(t, "user2") | ||
req = NewRequest(t, "GET", "/admin/users/1") | ||
session.MakeRequest(t, req, http.StatusForbidden) | ||
} | ||
|
||
func TestAdminEditUser(t *testing.T) { | ||
prepareTestEnv(t) | ||
|
||
testSuccessfullEdit(t, models.User{ID: 2, Name: "newusername", LoginName: "otherlogin", Email: "[email protected]"}) | ||
} | ||
|
||
func testSuccessfullEdit(t *testing.T, formData models.User) { | ||
makeRequest(t, formData, http.StatusFound) | ||
} | ||
|
||
func makeRequest(t *testing.T, formData models.User, headerCode int) { | ||
session := loginUser(t, "user1") | ||
csrf := GetCSRF(t, session, "/admin/users/"+strconv.Itoa(int(formData.ID))) | ||
req := NewRequestWithValues(t, "POST", "/admin/users/"+strconv.Itoa(int(formData.ID)), map[string]string{ | ||
"_csrf": csrf, | ||
"user_name": formData.Name, | ||
"login_name": formData.LoginName, | ||
"login_type": "0-0", | ||
"email": formData.Email, | ||
}) | ||
|
||
session.MakeRequest(t, req, headerCode) | ||
user := models.AssertExistsAndLoadBean(t, &models.User{ID: formData.ID}).(*models.User) | ||
assert.Equal(t, formData.Name, user.Name) | ||
assert.Equal(t, formData.LoginName, user.LoginName) | ||
assert.Equal(t, formData.Email, user.Email) | ||
} | ||
|
||
func TestAdminDeleteUser(t *testing.T) { | ||
prepareTestEnv(t) | ||
|
||
session := loginUser(t, "user1") | ||
|
||
csrf := GetCSRF(t, session, "/admin/users/8") | ||
req := NewRequestWithValues(t, "POST", "/admin/users/8/delete", map[string]string{ | ||
"_csrf": csrf, | ||
}) | ||
session.MakeRequest(t, req, http.StatusOK) | ||
|
||
models.AssertNotExistsBean(t, &models.User{ID: 8}) | ||
models.CheckConsistencyFor(t, &models.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
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.