From 5a021801d9eaa88cf17a202670c62bef25ab4472 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Thu, 29 Oct 2020 03:52:27 -0400 Subject: [PATCH] Remove obsolete change of email on profile page (#13341) (#13348) * 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 Co-authored-by: zeripath --- integrations/auth_ldap_test.go | 2 +- integrations/html_helper.go | 7 +++++++ modules/auth/user_form.go | 16 ++++++++-------- routers/user/setting/profile.go | 1 - templates/user/settings/profile.tmpl | 4 ++-- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/integrations/auth_ldap_test.go b/integrations/auth_ldap_test.go index 520a611eab..1569458418 100644 --- a/integrations/auth_ldap_test.go +++ b/integrations/auth_ldap_test.go @@ -141,7 +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.GetInputValueByName("email")) + assert.Equal(t, u.Email, htmlDoc.Find(`label[for="email"]`).Siblings().First().Text()) } func TestLDAPUserSync(t *testing.T) { diff --git a/integrations/html_helper.go b/integrations/html_helper.go index 823ed44851..6dc806a76e 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") diff --git a/modules/auth/user_form.go b/modules/auth/user_form.go index 228e17dce5..a87404fe8c 100644 --- a/modules/auth/user_form.go +++ b/modules/auth/user_form.go @@ -196,14 +196,14 @@ func (f *AccessTokenForm) Validate(ctx *macaron.Context, errs binding.Errors) bi // UpdateProfileForm form for updating profile 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)"` - Language string `binding:"Size(5)"` - Description string `binding:"MaxSize(255)"` + Name string `binding:"AlphaDashDot;MaxSize(40)"` + FullName string `binding:"MaxSize(100)"` + KeepEmailPrivate bool + Website string `binding:"ValidUrl;MaxSize(255)"` + Location string `binding:"MaxSize(50)"` + Language string `binding:"Size(5)"` + Description string `binding:"MaxSize(255)"` + KeepActivityPrivate bool } // Validate validates the fields diff --git a/routers/user/setting/profile.go b/routers/user/setting/profile.go index d6f25f9135..6ed0fe2eeb 100644 --- a/routers/user/setting/profile.go +++ b/routers/user/setting/profile.go @@ -90,7 +90,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 995bdfd638..d16ebc5f53 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -21,9 +21,9 @@ -
+
- +

{{.SignedUser.Email}}