Browse Source

Return 404 on user not found (#15606)

Return 404 on user not found

closes #10506
Samuel 6 years ago
parent
commit
41024c29bb
1 changed files with 4 additions and 4 deletions
  1. 4 4
      pkg/api/org_invite.go

+ 4 - 4
pkg/api/org_invite.go

@@ -27,6 +27,10 @@ func GetPendingOrgInvites(c *m.ReqContext) Response {
 }
 }
 
 
 func AddOrgInvite(c *m.ReqContext, inviteDto dtos.AddInviteForm) Response {
 func AddOrgInvite(c *m.ReqContext, inviteDto dtos.AddInviteForm) Response {
+	if setting.DisableLoginForm {
+		return Error(400, "Cannot invite when login is disabled.", nil)
+	}
+
 	if !inviteDto.Role.IsValid() {
 	if !inviteDto.Role.IsValid() {
 		return Error(400, "Invalid role specified", nil)
 		return Error(400, "Invalid role specified", nil)
 	}
 	}
@@ -37,10 +41,6 @@ func AddOrgInvite(c *m.ReqContext, inviteDto dtos.AddInviteForm) Response {
 		if err != m.ErrUserNotFound {
 		if err != m.ErrUserNotFound {
 			return Error(500, "Failed to query db for existing user check", err)
 			return Error(500, "Failed to query db for existing user check", err)
 		}
 		}
-
-		if setting.DisableLoginForm {
-			return Error(401, "User could not be found", nil)
-		}
 	} else {
 	} else {
 		return inviteExistingUserToOrg(c, userQuery.Result, &inviteDto)
 		return inviteExistingUserToOrg(c, userQuery.Result, &inviteDto)
 	}
 	}