-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Unify user update methods #28733
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
Unify user update methods #28733
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ef477dd
Unify user update methods.
KN4CK3R 386fc5a
Merge branch 'main' of https://github.com/go-gitea/gitea into refacto…
KN4CK3R 89f71f6
Merge branch 'main' of https://github.com/go-gitea/gitea into refacto…
KN4CK3R 2b97dbc
Add suggestions.
KN4CK3R 15b6e90
Fix return.
KN4CK3R d8d87b3
Fix test.
KN4CK3R 84aa00e
Use `db.DeleteByID`.
KN4CK3R b50590e
Merge branch 'main' of https://github.com/go-gitea/gitea into refacto…
KN4CK3R f339316
Merge branch 'main' of https://github.com/go-gitea/gitea into refacto…
KN4CK3R f04b039
Merge branch 'main' into refactor-user-service
GiteaBot 5792d59
Merge branch 'main' of https://github.com/go-gitea/gitea into refacto…
KN4CK3R 3550833
Merge branch 'main' into refactor-user-service
GiteaBot 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,3 +285,11 @@ | |
lower_email: [email protected] | ||
is_activated: true | ||
is_primary: false | ||
|
||
- | ||
id: 37 | ||
uid: 37 | ||
email: [email protected] | ||
lower_email: [email protected] | ||
is_activated: true | ||
is_primary: true |
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 |
---|---|---|
|
@@ -1095,7 +1095,7 @@ | |
allow_git_hook: false | ||
allow_import_local: false | ||
allow_create_organization: true | ||
prohibit_login: true | ||
prohibit_login: false | ||
avatar: avatar29 | ||
avatar_email: [email protected] | ||
use_custom_avatar: false | ||
|
@@ -1332,3 +1332,40 @@ | |
repo_admin_change_team_access: false | ||
theme: "" | ||
keep_activity_private: false | ||
|
||
- | ||
id: 37 | ||
lower_name: user37 | ||
name: user37 | ||
full_name: User 37 | ||
email: [email protected] | ||
keep_email_private: false | ||
email_notifications_preference: enabled | ||
passwd: ZogKvWdyEx:password | ||
passwd_hash_algo: dummy | ||
must_change_password: false | ||
login_source: 0 | ||
login_name: user37 | ||
type: 0 | ||
salt: ZogKvWdyEx | ||
max_repo_creation: -1 | ||
is_active: true | ||
is_admin: false | ||
is_restricted: false | ||
allow_git_hook: false | ||
allow_import_local: false | ||
allow_create_organization: true | ||
prohibit_login: true | ||
avatar: avatar29 | ||
avatar_email: [email protected] | ||
use_custom_avatar: false | ||
num_followers: 0 | ||
num_following: 0 | ||
num_stars: 0 | ||
num_repos: 0 | ||
num_teams: 0 | ||
num_members: 0 | ||
visibility: 0 | ||
repo_admin_change_team_access: false | ||
theme: "" | ||
keep_activity_private: false |
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 |
---|---|---|
|
@@ -42,96 +42,6 @@ func TestIsEmailUsed(t *testing.T) { | |
assert.False(t, isExist) | ||
} | ||
|
||
func TestAddEmailAddress(t *testing.T) { | ||
assert.NoError(t, unittest.PrepareTestDatabase()) | ||
|
||
assert.NoError(t, user_model.AddEmailAddress(db.DefaultContext, &user_model.EmailAddress{ | ||
Email: "[email protected]", | ||
LowerEmail: "[email protected]", | ||
IsPrimary: true, | ||
IsActivated: true, | ||
})) | ||
|
||
// ErrEmailAlreadyUsed | ||
err := user_model.AddEmailAddress(db.DefaultContext, &user_model.EmailAddress{ | ||
Email: "[email protected]", | ||
LowerEmail: "[email protected]", | ||
}) | ||
assert.Error(t, err) | ||
assert.True(t, user_model.IsErrEmailAlreadyUsed(err)) | ||
} | ||
|
||
func TestAddEmailAddresses(t *testing.T) { | ||
assert.NoError(t, unittest.PrepareTestDatabase()) | ||
|
||
// insert multiple email address | ||
emails := make([]*user_model.EmailAddress, 2) | ||
emails[0] = &user_model.EmailAddress{ | ||
Email: "[email protected]", | ||
LowerEmail: "[email protected]", | ||
IsActivated: true, | ||
} | ||
emails[1] = &user_model.EmailAddress{ | ||
Email: "[email protected]", | ||
LowerEmail: "[email protected]", | ||
IsActivated: true, | ||
} | ||
assert.NoError(t, user_model.AddEmailAddresses(db.DefaultContext, emails)) | ||
|
||
// ErrEmailAlreadyUsed | ||
err := user_model.AddEmailAddresses(db.DefaultContext, emails) | ||
assert.Error(t, err) | ||
assert.True(t, user_model.IsErrEmailAlreadyUsed(err)) | ||
} | ||
|
||
func TestDeleteEmailAddress(t *testing.T) { | ||
assert.NoError(t, unittest.PrepareTestDatabase()) | ||
|
||
assert.NoError(t, user_model.DeleteEmailAddress(db.DefaultContext, &user_model.EmailAddress{ | ||
UID: int64(1), | ||
ID: int64(33), | ||
Email: "[email protected]", | ||
LowerEmail: "[email protected]", | ||
})) | ||
|
||
assert.NoError(t, user_model.DeleteEmailAddress(db.DefaultContext, &user_model.EmailAddress{ | ||
UID: int64(1), | ||
Email: "[email protected]", | ||
LowerEmail: "[email protected]", | ||
})) | ||
|
||
// Email address does not exist | ||
err := user_model.DeleteEmailAddress(db.DefaultContext, &user_model.EmailAddress{ | ||
UID: int64(1), | ||
Email: "[email protected]", | ||
LowerEmail: "[email protected]", | ||
}) | ||
assert.Error(t, err) | ||
} | ||
|
||
func TestDeleteEmailAddresses(t *testing.T) { | ||
assert.NoError(t, unittest.PrepareTestDatabase()) | ||
|
||
// delete multiple email address | ||
emails := make([]*user_model.EmailAddress, 2) | ||
emails[0] = &user_model.EmailAddress{ | ||
UID: int64(2), | ||
ID: int64(3), | ||
Email: "[email protected]", | ||
LowerEmail: "[email protected]", | ||
} | ||
emails[1] = &user_model.EmailAddress{ | ||
UID: int64(2), | ||
Email: "[email protected]", | ||
LowerEmail: "[email protected]", | ||
} | ||
assert.NoError(t, user_model.DeleteEmailAddresses(db.DefaultContext, emails)) | ||
|
||
// ErrEmailAlreadyUsed | ||
err := user_model.DeleteEmailAddresses(db.DefaultContext, emails) | ||
assert.Error(t, err) | ||
} | ||
|
||
func TestMakeEmailPrimary(t *testing.T) { | ||
assert.NoError(t, unittest.PrepareTestDatabase()) | ||
|
||
|
Oops, something went wrong.
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.