[MM-47982] [MM-47983] Honor the ShowEmailAddress setting (#21707)
* Honor the ShowEmailAddress setting for the `/api/v4/teams/[teamid]/regenerate_invite_id` and `/api/v4/users/me/teams` API paths. Fixes MM-47982 and MM-47983 * Fix linter error in test code * MM-48186: Add a new API endpoint to add a user to their default GroupChannels and GroupTeams. (#21591) * MM-48186: Add a new API endpoint to add a user to their default GroupChannels and GroupTeams. * MM-48186: Removed unrelated lint fixes. * MM-48186: Removed variable from previous iteration. * MM-48186: Adds translation. * MM-48186: Not upgrading golang.org/x/text in this pr. * MM-48186: Validate user ID and auth service. * MM-48186: Use user id from struct. * MM-48186: Added basic client test. * MM-48186: Adds empty translation. * MM-48186: Added translations. Co-authored-by: Mattermod <mattermod@users.noreply.github.com> * [MM-47384] Make OpenID Connect free for all (#21556) * wip: make OpenID Connect free-for-all * Deprecation note: GoogleOAuth, Office365OAuth * Improve deprecation comments Co-authored-by: Martin Kraft <martin@upspin.org> * Lint fix * Add model/oauthproviders, move google, openid, office365 from enterprise * Vet fixes * Remove redundant log Co-authored-by: Martin Kraft <martin@upspin.org> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Martin Kraft <martin@upspin.org> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Shivashis Padhi <shivashispadhi@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b4d0c419d7
Коммит
860989e2ca
10
api4/team.go
10
api4/team.go
@@ -407,6 +407,10 @@ func regenerateTeamInviteId(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
|
||||
c.App.SanitizeTeam(*c.AppContext.Session(), patchedTeam)
|
||||
|
||||
if !*c.App.Config().PrivacySettings.ShowEmailAddress && !c.IsSystemAdmin() {
|
||||
patchedTeam.Email = ""
|
||||
}
|
||||
|
||||
auditRec.Success()
|
||||
auditRec.AddEventResultState(patchedTeam)
|
||||
auditRec.AddEventObjectType("team")
|
||||
@@ -493,6 +497,12 @@ func getTeamsForUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
c.App.SanitizeTeams(*c.AppContext.Session(), teams)
|
||||
|
||||
if !*c.App.Config().PrivacySettings.ShowEmailAddress && !c.IsSystemAdmin() {
|
||||
for _, team := range teams {
|
||||
team.Email = ""
|
||||
}
|
||||
}
|
||||
|
||||
js, err := json.Marshal(teams)
|
||||
if err != nil {
|
||||
c.Err = model.NewAppError("getTeamsForUser", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
|
||||
@@ -871,11 +871,21 @@ func TestRegenerateTeamInviteId(t *testing.T) {
|
||||
assert.NotEqual(t, team.InviteId, "")
|
||||
assert.NotEqual(t, team.InviteId, "inviteid0")
|
||||
|
||||
*th.App.Config().PrivacySettings.ShowEmailAddress = true
|
||||
rteam, _, err := client.RegenerateTeamInviteId(team.Id)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.NotEqual(t, team.InviteId, rteam.InviteId)
|
||||
assert.NotEqual(t, team.InviteId, "")
|
||||
assert.NotEqual(t, rteam.Email, "")
|
||||
|
||||
*th.App.Config().PrivacySettings.ShowEmailAddress = false
|
||||
rteam, _, err = client.RegenerateTeamInviteId(team.Id)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.NotEqual(t, team.InviteId, rteam.InviteId)
|
||||
assert.NotEqual(t, team.InviteId, "")
|
||||
assert.Equal(t, rteam.Email, "")
|
||||
}
|
||||
|
||||
func TestSoftDeleteTeam(t *testing.T) {
|
||||
@@ -1819,6 +1829,17 @@ func TestGetTeamsForUserSanitization(t *testing.T) {
|
||||
require.NotEmpty(t, rteam.Email, "should not have sanitized email")
|
||||
require.NotEmpty(t, rteam.InviteId, "should have not sanitized inviteid")
|
||||
}
|
||||
*th.App.Config().PrivacySettings.ShowEmailAddress = false
|
||||
rteams, _, err2 := th.Client.GetTeamsForUser(th.BasicUser.Id, "")
|
||||
require.NoError(t, err2)
|
||||
for _, rteam := range rteams {
|
||||
if rteam.Id != team.Id && rteam.Id != team2.Id {
|
||||
continue
|
||||
}
|
||||
|
||||
require.Empty(t, rteam.Email, "should have sanitized email")
|
||||
require.NotEmpty(t, rteam.InviteId, "should have not sanitized inviteid")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("system admin", func(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user