Fixed error information being obscured when joining teams with API v4 (#6751)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
4484c82b1b
Коммит
c66799a839
@@ -373,14 +373,8 @@ func addUserToTeamFromInvite(c *Context, w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
if len(hash) > 0 && len(data) > 0 {
|
if len(hash) > 0 && len(data) > 0 {
|
||||||
member, err = app.AddTeamMemberByHash(c.Session.UserId, hash, data)
|
member, err = app.AddTeamMemberByHash(c.Session.UserId, hash, data)
|
||||||
if err != nil {
|
|
||||||
err = model.NewAppError("addTeamMember", "api.team.add_user_to_team.invalid_data.app_error", nil, "", http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
} else if len(inviteId) > 0 {
|
} else if len(inviteId) > 0 {
|
||||||
member, err = app.AddTeamMemberByInviteId(inviteId, c.Session.UserId)
|
member, err = app.AddTeamMemberByInviteId(inviteId, c.Session.UserId)
|
||||||
if err != nil {
|
|
||||||
err = model.NewAppError("addTeamMember", "api.team.add_user_to_team.invalid_invite_id.app_error", nil, "", http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
err = model.NewAppError("addTeamMember", "api.team.add_user_to_team.missing_parameter.app_error", nil, "", http.StatusBadRequest)
|
err = model.NewAppError("addTeamMember", "api.team.add_user_to_team.missing_parameter.app_error", nil, "", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -781,7 +781,7 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
tm, resp := Client.AddTeamMember(team.Id, otherUser.Id)
|
tm, resp := Client.AddTeamMember(team.Id, otherUser.Id)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
if resp.Error == nil {
|
if resp.Error == nil {
|
||||||
t.Fatalf("ERror is nhul")
|
t.Fatalf("Error is nhul")
|
||||||
}
|
}
|
||||||
Client.Logout()
|
Client.Logout()
|
||||||
|
|
||||||
@@ -971,14 +971,11 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tm, resp = Client.AddTeamMemberFromInvite("", "", "junk")
|
tm, resp = Client.AddTeamMemberFromInvite("", "", "junk")
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckNotFoundStatus(t, resp)
|
||||||
|
|
||||||
if tm != nil {
|
if tm != nil {
|
||||||
t.Fatal("should have not returned team member")
|
t.Fatal("should have not returned team member")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, resp = Client.AddTeamMemberFromInvite("", "", "junk")
|
|
||||||
CheckBadRequestStatus(t, resp)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAddTeamMembers(t *testing.T) {
|
func TestAddTeamMembers(t *testing.T) {
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ func TestCreateUserWithInviteId(t *testing.T) {
|
|||||||
inviteId := model.NewId()
|
inviteId := model.NewId()
|
||||||
|
|
||||||
_, resp := Client.CreateUserWithInviteId(&user, inviteId)
|
_, resp := Client.CreateUserWithInviteId(&user, inviteId)
|
||||||
CheckInternalErrorStatus(t, resp)
|
CheckNotFoundStatus(t, resp)
|
||||||
CheckErrorMessage(t, resp, "store.sql_team.get_by_invite_id.find.app_error")
|
CheckErrorMessage(t, resp, "store.sql_team.get_by_invite_id.find.app_error")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ func TestCreateUserWithInviteId(t *testing.T) {
|
|||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
_, resp = Client.CreateUserWithInviteId(&user, inviteId)
|
_, resp = Client.CreateUserWithInviteId(&user, inviteId)
|
||||||
CheckInternalErrorStatus(t, resp)
|
CheckNotFoundStatus(t, resp)
|
||||||
CheckErrorMessage(t, resp, "store.sql_team.get_by_invite_id.find.app_error")
|
CheckErrorMessage(t, resp, "store.sql_team.get_by_invite_id.find.app_error")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -199,12 +199,12 @@ func AddUserToTeamByHash(userId string, hash string, data string) (*model.Team,
|
|||||||
props := model.MapFromJson(strings.NewReader(data))
|
props := model.MapFromJson(strings.NewReader(data))
|
||||||
|
|
||||||
if hash != utils.HashSha256(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt)) {
|
if hash != utils.HashSha256(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt)) {
|
||||||
return nil, model.NewLocAppError("JoinUserToTeamByHash", "api.user.create_user.signup_link_invalid.app_error", nil, "")
|
return nil, model.NewAppError("JoinUserToTeamByHash", "api.user.create_user.signup_link_invalid.app_error", nil, "", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
t, timeErr := strconv.ParseInt(props["time"], 10, 64)
|
t, timeErr := strconv.ParseInt(props["time"], 10, 64)
|
||||||
if timeErr != nil || model.GetMillis()-t > 1000*60*60*48 { // 48 hours
|
if timeErr != nil || model.GetMillis()-t > 1000*60*60*48 { // 48 hours
|
||||||
return nil, model.NewLocAppError("JoinUserToTeamByHash", "api.user.create_user.signup_link_expired.app_error", nil, "")
|
return nil, model.NewAppError("JoinUserToTeamByHash", "api.user.create_user.signup_link_expired.app_error", nil, "", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
tchan := Srv.Store.Team().Get(props["id"])
|
tchan := Srv.Store.Team().Get(props["id"])
|
||||||
|
|||||||
@@ -2003,14 +2003,6 @@
|
|||||||
"id": "api.system.go_routines",
|
"id": "api.system.go_routines",
|
||||||
"translation": "The number of running goroutines is over the health threshold %v of %v"
|
"translation": "The number of running goroutines is over the health threshold %v of %v"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "api.team.add_user_to_team.invalid_data.app_error",
|
|
||||||
"translation": "Invalid data."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "api.team.add_user_to_team.invalid_invite_id.app_error",
|
|
||||||
"translation": "Invalid invite id. No team matches with this invite id."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "api.team.add_user_to_team.missing_parameter.app_error",
|
"id": "api.team.add_user_to_team.missing_parameter.app_error",
|
||||||
"translation": "Parameter required to add user to team."
|
"translation": "Parameter required to add user to team."
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ func (s SqlTeamStore) GetByInviteId(inviteId string) StoreChannel {
|
|||||||
team := model.Team{}
|
team := model.Team{}
|
||||||
|
|
||||||
if err := s.GetReplica().SelectOne(&team, "SELECT * FROM Teams WHERE Id = :InviteId OR InviteId = :InviteId", map[string]interface{}{"InviteId": inviteId}); err != nil {
|
if err := s.GetReplica().SelectOne(&team, "SELECT * FROM Teams WHERE Id = :InviteId OR InviteId = :InviteId", map[string]interface{}{"InviteId": inviteId}); err != nil {
|
||||||
result.Err = model.NewLocAppError("SqlTeamStore.GetByInviteId", "store.sql_team.get_by_invite_id.finding.app_error", nil, "inviteId="+inviteId+", "+err.Error())
|
result.Err = model.NewAppError("SqlTeamStore.GetByInviteId", "store.sql_team.get_by_invite_id.finding.app_error", nil, "inviteId="+inviteId+", "+err.Error(), http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(team.InviteId) == 0 {
|
if len(team.InviteId) == 0 {
|
||||||
@@ -199,7 +199,7 @@ func (s SqlTeamStore) GetByInviteId(inviteId string) StoreChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(inviteId) == 0 || team.InviteId != inviteId {
|
if len(inviteId) == 0 || team.InviteId != inviteId {
|
||||||
result.Err = model.NewLocAppError("SqlTeamStore.GetByInviteId", "store.sql_team.get_by_invite_id.find.app_error", nil, "inviteId="+inviteId)
|
result.Err = model.NewAppError("SqlTeamStore.GetByInviteId", "store.sql_team.get_by_invite_id.find.app_error", nil, "inviteId="+inviteId, http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Data = &team
|
result.Data = &team
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export default class SignupController extends React.Component {
|
|||||||
|
|
||||||
handleInvalidInvite = (err) => {
|
handleInvalidInvite = (err) => {
|
||||||
let serverError;
|
let serverError;
|
||||||
if (err.id === 'store.sql_user.save.max_accounts.app_error') {
|
if (err.server_error_id === 'store.sql_user.save.max_accounts.app_error') {
|
||||||
serverError = err.message;
|
serverError = err.message;
|
||||||
} else {
|
} else {
|
||||||
serverError = (
|
serverError = (
|
||||||
@@ -209,7 +209,7 @@ export default class SignupController extends React.Component {
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global.window.mm_license.IsLicensed === 'true' && global.window.mm_config.EnableLdap === 'true') {
|
if (global.window.mm_license.IsLicensed === 'true' && global.window.mm_config.EnableLdap === 'true') {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user