Merge pull request 'UI: Hide hidden email from own profile, again' (#3636) from n0toose/profile/hide-unhidden-hidden-email into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3636 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
commit
3f6e4af5a9
3 changed files with 13 additions and 25 deletions
|
@ -676,7 +676,6 @@ unblock = Unblock
|
||||||
user_bio = Biography
|
user_bio = Biography
|
||||||
disabled_public_activity = This user has disabled the public visibility of the activity.
|
disabled_public_activity = This user has disabled the public visibility of the activity.
|
||||||
email_visibility.limited = Your email address is visible to all authenticated users
|
email_visibility.limited = Your email address is visible to all authenticated users
|
||||||
email_visibility.private = Your email address is only visible to you and administrators
|
|
||||||
show_on_map = Show this place on a map
|
show_on_map = Show this place on a map
|
||||||
settings = User settings
|
settings = User settings
|
||||||
|
|
||||||
|
|
|
@ -38,29 +38,18 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if (eq .SignedUserID .ContextUser.ID)}}
|
{{if .ShowUserEmail}}
|
||||||
<li>
|
|
||||||
{{svg "octicon-mail"}}
|
|
||||||
<a class="tw-flex-1" href="mailto:{{.ContextUser.Email}}" rel="nofollow">{{.ContextUser.Email}}</a>
|
|
||||||
<a href="{{AppSubUrl}}/user/settings#privacy-user-settings">
|
|
||||||
{{if .ShowUserEmail}}
|
|
||||||
<i data-tooltip-content="{{ctx.Locale.Tr "user.email_visibility.limited"}}">
|
|
||||||
{{svg "octicon-unlock"}}
|
|
||||||
</i>
|
|
||||||
{{else}}
|
|
||||||
<i data-tooltip-content="{{ctx.Locale.Tr "user.email_visibility.private"}}">
|
|
||||||
{{svg "octicon-lock"}}
|
|
||||||
</i>
|
|
||||||
{{end}}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{{else}}
|
|
||||||
{{if .ShowUserEmail}}
|
|
||||||
<li>
|
<li>
|
||||||
{{svg "octicon-mail"}}
|
{{svg "octicon-mail"}}
|
||||||
<a href="mailto:{{.ContextUser.Email}}" rel="nofollow">{{.ContextUser.Email}}</a>
|
<a class="tw-flex-1" href="mailto:{{.ContextUser.Email}}" rel="nofollow">{{.ContextUser.Email}}</a>
|
||||||
|
{{if (eq .SignedUserID .ContextUser.ID)}}
|
||||||
|
<a href="{{AppSubUrl}}/user/settings#privacy-user-settings">
|
||||||
|
<i data-tooltip-content="{{ctx.Locale.Tr "user.email_visibility.limited"}}">
|
||||||
|
{{svg "octicon-unlock"}}
|
||||||
|
</i>
|
||||||
|
</a>
|
||||||
|
{{end}}
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .ContextUser.Website}}
|
{{if .ContextUser.Website}}
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -75,21 +75,21 @@ func TestSettingShowUserEmailProfile(t *testing.T) {
|
||||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||||
assert.Contains(t, htmlDoc.doc.Find(".user.profile").Text(), "user1@example.com")
|
assert.Contains(t, htmlDoc.doc.Find(".user.profile").Text(), "user1@example.com")
|
||||||
|
|
||||||
// user2 can see own hidden email
|
// user2 cannot see own hidden email
|
||||||
session = loginUser(t, "user2")
|
session = loginUser(t, "user2")
|
||||||
req = NewRequest(t, "GET", "/user2")
|
req = NewRequest(t, "GET", "/user2")
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||||
assert.Contains(t, htmlDoc.doc.Find(".user.profile").Text(), "user2@example.com")
|
assert.NotContains(t, htmlDoc.doc.Find(".user.profile").Text(), "user2@example.com")
|
||||||
|
|
||||||
setting.UI.ShowUserEmail = false
|
setting.UI.ShowUserEmail = false
|
||||||
|
|
||||||
// user1 can see own (now hidden) email
|
// user1 cannot see own (now hidden) email
|
||||||
session = loginUser(t, "user1")
|
session = loginUser(t, "user1")
|
||||||
req = NewRequest(t, "GET", "/user1")
|
req = NewRequest(t, "GET", "/user1")
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||||
assert.Contains(t, htmlDoc.doc.Find(".user.profile").Text(), "user1@example.com")
|
assert.NotContains(t, htmlDoc.doc.Find(".user.profile").Text(), "user1@example.com")
|
||||||
|
|
||||||
setting.UI.ShowUserEmail = showUserEmail
|
setting.UI.ShowUserEmail = showUserEmail
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue