mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-07-12 06:59:24 +02:00
Compare commits
3 commits
1ed750a33a
...
bcde3aea4f
Author | SHA1 | Date | |
---|---|---|---|
|
bcde3aea4f | ||
|
abb95c8c92 | ||
|
0ecd9d9682 |
8 changed files with 47 additions and 11 deletions
2
go.mod
2
go.mod
|
@ -42,7 +42,7 @@ require (
|
|||
github.com/go-ap/activitypub v0.0.0-20231114162308-e219254dc5c9
|
||||
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73
|
||||
github.com/go-chi/chi/v5 v5.2.2
|
||||
github.com/go-chi/cors v1.2.1
|
||||
github.com/go-chi/cors v1.2.2
|
||||
github.com/go-co-op/gocron v1.37.0
|
||||
github.com/go-enry/go-enry/v2 v2.9.2
|
||||
github.com/go-git/go-git/v5 v5.13.2
|
||||
|
|
4
go.sum
4
go.sum
|
@ -215,8 +215,8 @@ github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkPro
|
|||
github.com/go-chi/chi/v5 v5.0.1/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||
github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618=
|
||||
github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
|
||||
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
|
||||
github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
|
||||
github.com/go-chi/cors v1.2.2 h1:Jmey33TE+b+rB7fT8MUy1u0I4L+NARQlK6LhzKPSyQE=
|
||||
github.com/go-chi/cors v1.2.2/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
|
||||
github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0=
|
||||
github.com/go-co-op/gocron v1.37.0/go.mod h1:3L/n6BkO7ABj+TrfSVXLRzsP26zmikL4ISkLQ0O8iNY=
|
||||
github.com/go-enry/go-enry/v2 v2.9.2 h1:giOQAtCgBX08kosrX818DCQJTCNtKwoPBGu0qb6nKTY=
|
||||
|
|
7
models/fixtures/TestActivateUserEmail/email_address.yml
Normal file
7
models/fixtures/TestActivateUserEmail/email_address.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
-
|
||||
id: 1001
|
||||
uid: 1001
|
||||
email: AnotherTestUserWithUpperCaseEmail@otto.splvs.net
|
||||
lower_email: anothertestuserwithuppercaseemail@otto.splvs.net
|
||||
is_activated: false
|
||||
is_primary: true
|
12
models/fixtures/TestActivateUserEmail/user.yml
Normal file
12
models/fixtures/TestActivateUserEmail/user.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
-
|
||||
id: 1001
|
||||
lower_name: user1001
|
||||
name: user1001
|
||||
full_name: User That loves Upper Cases
|
||||
email: AnotherTestUserWithUpperCaseEmail@otto.splvs.net
|
||||
passwd: ZogKvWdyEx:password
|
||||
passwd_hash_algo: dummy
|
||||
avatar: ''
|
||||
avatar_email: anothertestuserwithuppercaseemail@otto.splvs.net
|
||||
login_name: user1
|
||||
created_unix: 1672578000
|
|
@ -181,3 +181,20 @@ func TestDeletePrimaryEmailAddressOfUser(t *testing.T) {
|
|||
assert.True(t, user_model.IsErrEmailAddressNotExist(err))
|
||||
assert.Nil(t, email)
|
||||
}
|
||||
|
||||
func TestActivateUserEmail(t *testing.T) {
|
||||
defer unittest.OverrideFixtures("models/fixtures/TestActivateUserEmail")()
|
||||
require.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
t.Run("Activate email", func(t *testing.T) {
|
||||
require.NoError(t, user_model.ActivateUserEmail(t.Context(), 1001, "AnotherTestUserWithUpperCaseEmail@otto.splvs.net", true))
|
||||
|
||||
unittest.AssertExistsAndLoadBean(t, &user_model.EmailAddress{UID: 1001}, "is_activated = true")
|
||||
})
|
||||
|
||||
t.Run("Deactivate email", func(t *testing.T) {
|
||||
require.NoError(t, user_model.ActivateUserEmail(t.Context(), 1001, "AnotherTestUserWithUpperCaseEmail@otto.splvs.net", false))
|
||||
|
||||
unittest.AssertExistsAndLoadBean(t, &user_model.EmailAddress{UID: 1001}, "is_activated = false")
|
||||
})
|
||||
}
|
||||
|
|
|
@ -182,11 +182,11 @@ func (u *User) BeforeUpdate() {
|
|||
u.MaxRepoCreation = -1
|
||||
}
|
||||
|
||||
// Organization does not need email
|
||||
u.Email = strings.ToLower(u.Email)
|
||||
// Ensure AvatarEmail is set for non-organization users, because organization
|
||||
// are not required to have a email set.
|
||||
if !u.IsOrganization() {
|
||||
if len(u.AvatarEmail) == 0 {
|
||||
u.AvatarEmail = u.Email
|
||||
u.AvatarEmail = strings.ToLower(u.Email)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
8
package-lock.json
generated
8
package-lock.json
generated
|
@ -86,7 +86,7 @@
|
|||
"eslint-plugin-vue": "10.2.0",
|
||||
"eslint-plugin-vue-scoped-css": "2.10.0",
|
||||
"eslint-plugin-wc": "3.0.1",
|
||||
"globals": "16.1.0",
|
||||
"globals": "16.3.0",
|
||||
"happy-dom": "18.0.1",
|
||||
"license-checker-rseidelsohn": "4.4.2",
|
||||
"markdownlint-cli": "0.45.0",
|
||||
|
@ -8440,9 +8440,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/globals": {
|
||||
"version": "16.1.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-16.1.0.tgz",
|
||||
"integrity": "sha512-aibexHNbb/jiUSObBgpHLj+sIuUmJnYcgXBlrfsiDZ9rt4aF2TFRbyLgZ2iFQuVZ1K5Mx3FVkbKRSgKrbK3K2g==",
|
||||
"version": "16.3.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-16.3.0.tgz",
|
||||
"integrity": "sha512-bqWEnJ1Nt3neqx2q5SFfGS8r/ahumIakg3HcwtNlrVlwXIeNumWn/c7Pn/wKzGhf6SaW6H6uWXLqC30STCMchQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
"eslint-plugin-vue": "10.2.0",
|
||||
"eslint-plugin-vue-scoped-css": "2.10.0",
|
||||
"eslint-plugin-wc": "3.0.1",
|
||||
"globals": "16.1.0",
|
||||
"globals": "16.3.0",
|
||||
"happy-dom": "18.0.1",
|
||||
"license-checker-rseidelsohn": "4.4.2",
|
||||
"markdownlint-cli": "0.45.0",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue