Minor updates to team
Этот коммит содержится в:
@@ -85,7 +85,7 @@ func getTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.Err = err
|
||||
return
|
||||
} else {
|
||||
if team.Type != model.TEAM_OPEN && !app.SessionHasPermissionToTeam(c.Session, team.Id, model.PERMISSION_VIEW_TEAM) {
|
||||
if (!team.AllowOpenInvite || team.Type != model.TEAM_OPEN) && !app.SessionHasPermissionToTeam(c.Session, team.Id, model.PERMISSION_VIEW_TEAM) {
|
||||
c.SetPermissionError(model.PERMISSION_VIEW_TEAM)
|
||||
return
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func getTeamByName(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.Err = err
|
||||
return
|
||||
} else {
|
||||
if team.Type != model.TEAM_OPEN && !app.SessionHasPermissionToTeam(c.Session, team.Id, model.PERMISSION_VIEW_TEAM) {
|
||||
if (!team.AllowOpenInvite || team.Type != model.TEAM_OPEN) && !app.SessionHasPermissionToTeam(c.Session, team.Id, model.PERMISSION_VIEW_TEAM) {
|
||||
c.SetPermissionError(model.PERMISSION_VIEW_TEAM)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -106,13 +106,21 @@ func TestGetTeam(t *testing.T) {
|
||||
|
||||
th.LoginTeamAdmin()
|
||||
|
||||
team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_INVITE}
|
||||
team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_OPEN, AllowOpenInvite: false}
|
||||
rteam2, _ := Client.CreateTeam(team2)
|
||||
|
||||
team3 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_INVITE, AllowOpenInvite: true}
|
||||
rteam3, _ := Client.CreateTeam(team3)
|
||||
|
||||
th.LoginBasic()
|
||||
// AllowInviteOpen is false and team is open, and user is not on team
|
||||
_, resp = Client.GetTeam(rteam2.Id, "")
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// AllowInviteOpen is true and team is invite, and user is not on team
|
||||
_, resp = Client.GetTeam(rteam3.Id, "")
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
Client.Logout()
|
||||
_, resp = Client.GetTeam(team.Id, "")
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
@@ -474,12 +482,20 @@ func TestGetTeamByName(t *testing.T) {
|
||||
|
||||
th.LoginTeamAdmin()
|
||||
|
||||
team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_INVITE}
|
||||
team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_OPEN, AllowOpenInvite: false}
|
||||
rteam2, _ := Client.CreateTeam(team2)
|
||||
|
||||
team3 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_INVITE, AllowOpenInvite: true}
|
||||
rteam3, _ := Client.CreateTeam(team3)
|
||||
|
||||
th.LoginBasic()
|
||||
// AllowInviteOpen is false and team is open, and user is not on team
|
||||
_, resp = Client.GetTeamByName(rteam2.Name, "")
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// AllowInviteOpen is true and team is invite only, and user is not on team
|
||||
_, resp = Client.GetTeamByName(rteam3.Name, "")
|
||||
CheckForbiddenStatus(t, resp)
|
||||
}
|
||||
|
||||
func TestSearchAllTeams(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user