diff --git a/pkg/api/org_invite.go b/pkg/api/org_invite.go index 86067cd7721..4b731db5d3d 100644 --- a/pkg/api/org_invite.go +++ b/pkg/api/org_invite.go @@ -27,6 +27,10 @@ func GetPendingOrgInvites(c *m.ReqContext) 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() { return Error(400, "Invalid role specified", nil) } @@ -37,10 +41,6 @@ func AddOrgInvite(c *m.ReqContext, inviteDto dtos.AddInviteForm) Response { if err != m.ErrUserNotFound { 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 { return inviteExistingUserToOrg(c, userQuery.Result, &inviteDto) }