summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/channel.go5
-rw-r--r--api/channel_test.go19
-rw-r--r--api/file.go2
-rw-r--r--api/user.go10
4 files changed, 31 insertions, 5 deletions
diff --git a/api/channel.go b/api/channel.go
index 038a4286a..2e4eb2bb5 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -562,6 +562,11 @@ func AddUserToChannel(user *model.User, channel *model.Channel) (*model.ChannelM
if result := <-tmchan; result.Err != nil {
return nil, result.Err
+ } else {
+ teamMember := result.Data.(model.TeamMember)
+ if teamMember.DeleteAt > 0 {
+ return nil, model.NewLocAppError("AddUserToChannel", "api.channel.add_user.to.channel.failed.deleted.app_error", nil, "")
+ }
}
if result := <-cmchan; result.Err != nil {
diff --git a/api/channel_test.go b/api/channel_test.go
index 93d097261..450aac877 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -833,6 +833,25 @@ func TestJoinChannelByName(t *testing.T) {
}
}
+func TestJoinChannelByNameDisabledUser(t *testing.T) {
+ th := Setup().InitBasic()
+ Client := th.BasicClient
+ team := th.BasicTeam
+
+ channel1 := &model.Channel{DisplayName: "A Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
+ channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
+
+ Client.Must(th.BasicClient.RemoveUserFromTeam(th.BasicTeam.Id, th.BasicUser.Id))
+
+ if _, err := AddUserToChannel(th.BasicUser, channel1); err == nil {
+ t.Fatal("shoudn't be able to join channel")
+ } else {
+ if err.Id != "api.channel.add_user.to.channel.failed.deleted.app_error" {
+ t.Fatal("wrong error")
+ }
+ }
+}
+
func TestLeaveChannel(t *testing.T) {
th := Setup().InitBasic()
Client := th.BasicClient
diff --git a/api/file.go b/api/file.go
index 92bceaa80..5b08804da 100644
--- a/api/file.go
+++ b/api/file.go
@@ -356,7 +356,7 @@ func getFile(c *Context, w http.ResponseWriter, r *http.Request) {
userId := params["user_id"]
filename := params["filename"]
- if !c.HasPermissionsToChannel(Srv.Store.Channel().CheckPermissionsTo(teamId, channelId, userId), "getFile") {
+ if !c.HasPermissionsToChannel(Srv.Store.Channel().CheckPermissionsTo(teamId, channelId, c.Session.UserId), "getFile") {
return
}
diff --git a/api/user.go b/api/user.go
index daaa3a577..84906eece 100644
--- a/api/user.go
+++ b/api/user.go
@@ -449,8 +449,8 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
if result := <-Srv.Store.User().Get(id); result.Err != nil {
c.LogAuditWithUserId(user.Id, "failure")
- c.Err = result.Err
- c.Err.StatusCode = http.StatusBadRequest
+ //c.Err = model.NewLocAppError("login", "api.user.login.invalid_credentials", nil, result.Err.Error())
+ c.Err = model.NewLocAppError("login", "api.user.login.invalid_credentials", nil, "")
return
} else {
user = result.Data.(*model.User)
@@ -460,7 +460,8 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
if user, err = getUserForLogin(loginId, ldapOnly); err != nil {
c.LogAudit("failure")
- c.Err = err
+ //c.Err = model.NewLocAppError("login", "api.user.login.invalid_credentials", nil, err.Error())
+ c.Err = model.NewLocAppError("login", "api.user.login.invalid_credentials", nil, "")
return
}
@@ -470,7 +471,8 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
// and then authenticate them
if user, err = authenticateUser(user, password, mfaToken); err != nil {
c.LogAuditWithUserId(user.Id, "failure")
- c.Err = err
+ //c.Err = model.NewLocAppError("login", "api.user.login.invalid_credentials", nil, err.Error())
+ c.Err = model.NewLocAppError("login", "api.user.login.invalid_credentials", nil, "")
return
}