From 14a107472ef38775557dd8b4dc12648b02c12cdc Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Wed, 28 Oct 2020 17:55:31 +0000 Subject: [PATCH 1/3] Remove obsolete change of email on profile page The change email on the account profile page is out-of-date and unnecessary. Changing email should be done using the account page. Fix #13336 Signed-off-by: Andrew Thornton --- modules/auth/user_form.go | 1 - routers/user/setting/profile.go | 1 - templates/user/settings/profile.tmpl | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/auth/user_form.go b/modules/auth/user_form.go index e657f78e6de47..32fde1570ead2 100644 --- a/modules/auth/user_form.go +++ b/modules/auth/user_form.go @@ -199,7 +199,6 @@ func (f *AccessTokenForm) Validate(ctx *macaron.Context, errs binding.Errors) bi type UpdateProfileForm struct { Name string `binding:"AlphaDashDot;MaxSize(40)"` FullName string `binding:"MaxSize(100)"` - Email string `binding:"Required;Email;MaxSize(254)"` KeepEmailPrivate bool Website string `binding:"ValidUrl;MaxSize(255)"` Location string `binding:"MaxSize(50)"` diff --git a/routers/user/setting/profile.go b/routers/user/setting/profile.go index edb78031f2b34..6653230a39429 100644 --- a/routers/user/setting/profile.go +++ b/routers/user/setting/profile.go @@ -91,7 +91,6 @@ func ProfilePost(ctx *context.Context, form auth.UpdateProfileForm) { } ctx.User.FullName = form.FullName - ctx.User.Email = form.Email ctx.User.KeepEmailPrivate = form.KeepEmailPrivate ctx.User.Website = form.Website ctx.User.Location = form.Location diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index 1f34e24585d6d..ea895ecd894f9 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -21,9 +21,9 @@ -
+
- +

{{.SignedUser.Email}}

From 720bdf4c477d6f91b455cce1257334708e4b81a2 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Wed, 28 Oct 2020 19:07:21 +0000 Subject: [PATCH 2/3] fix test Signed-off-by: Andrew Thornton --- integrations/auth_ldap_test.go | 3 ++- integrations/html_helper.go | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/integrations/auth_ldap_test.go b/integrations/auth_ldap_test.go index 520a611eab136..cc15ac8d28d91 100644 --- a/integrations/auth_ldap_test.go +++ b/integrations/auth_ldap_test.go @@ -141,7 +141,8 @@ func TestLDAPUserSignin(t *testing.T) { assert.Equal(t, u.UserName, htmlDoc.GetInputValueByName("name")) assert.Equal(t, u.FullName, htmlDoc.GetInputValueByName("full_name")) - assert.Equal(t, u.Email, htmlDoc.GetInputValueByName("email")) + + assert.Equal(t, u.Email, htmlDoc.Find(`label[for="email"]`).Siblings()[0].Text()) } func TestLDAPUserSync(t *testing.T) { diff --git a/integrations/html_helper.go b/integrations/html_helper.go index 823ed44851532..6dc806a76ed26 100644 --- a/integrations/html_helper.go +++ b/integrations/html_helper.go @@ -37,6 +37,13 @@ func (doc *HTMLDoc) GetInputValueByName(name string) string { return text } +// Find gets the descendants of each element in the current set of +// matched elements, filtered by a selector. It returns a new Selection +// object containing these matched elements. +func (doc *HTMLDoc) Find(selector string) *goquery.Selection { + return doc.doc.Find(selector) +} + // GetCSRF for get CSRC token value from input func (doc *HTMLDoc) GetCSRF() string { return doc.GetInputValueByName("_csrf") From 019863c337088a2123d8b1883c106ce8706075f8 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Wed, 28 Oct 2020 19:08:00 +0000 Subject: [PATCH 3/3] argh Signed-off-by: Andrew Thornton --- integrations/auth_ldap_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/integrations/auth_ldap_test.go b/integrations/auth_ldap_test.go index cc15ac8d28d91..15694584186d0 100644 --- a/integrations/auth_ldap_test.go +++ b/integrations/auth_ldap_test.go @@ -141,8 +141,7 @@ func TestLDAPUserSignin(t *testing.T) { assert.Equal(t, u.UserName, htmlDoc.GetInputValueByName("name")) assert.Equal(t, u.FullName, htmlDoc.GetInputValueByName("full_name")) - - assert.Equal(t, u.Email, htmlDoc.Find(`label[for="email"]`).Siblings()[0].Text()) + assert.Equal(t, u.Email, htmlDoc.Find(`label[for="email"]`).Siblings().First().Text()) } func TestLDAPUserSync(t *testing.T) {