diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go
index c0e27897ff4..328b8abbc5f 100644
--- a/pkg/api/frontendsettings.go
+++ b/pkg/api/frontendsettings.go
@@ -142,6 +142,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
"ldapEnabled": setting.LdapEnabled,
"alertingEnabled": setting.AlertingEnabled,
"googleAnalyticsId": setting.GoogleAnalyticsId,
+ "disableLoginForm": setting.DisableLoginForm,
"buildInfo": map[string]interface{}{
"version": setting.BuildVersion,
"commit": setting.BuildCommit,
diff --git a/pkg/api/login.go b/pkg/api/login.go
index 8fbe414c08c..8ab76c7b48d 100644
--- a/pkg/api/login.go
+++ b/pkg/api/login.go
@@ -94,6 +94,10 @@ func LoginApiPing(c *middleware.Context) {
}
func LoginPost(c *middleware.Context, cmd dtos.LoginCommand) Response {
+ if setting.DisableLoginForm {
+ return ApiError(401, "Login is disabled", nil)
+ }
+
authQuery := login.LoginUserQuery{
Username: cmd.User,
Password: cmd.Password,
diff --git a/pkg/api/org_invite.go b/pkg/api/org_invite.go
index 8d916677ed2..9e85808950f 100644
--- a/pkg/api/org_invite.go
+++ b/pkg/api/org_invite.go
@@ -38,6 +38,10 @@ func AddOrgInvite(c *middleware.Context, inviteDto dtos.AddInviteForm) Response
if err != m.ErrUserNotFound {
return ApiError(500, "Failed to query db for existing user check", err)
}
+
+ if setting.DisableLoginForm {
+ return ApiError(401, "User could not be found", nil)
+ }
} else {
return inviteExistingUserToOrg(c, userQuery.Result, &inviteDto)
}
diff --git a/public/app/features/org/org_users_ctrl.ts b/public/app/features/org/org_users_ctrl.ts
index 9e70328f345..6181edddc9a 100644
--- a/public/app/features/org/org_users_ctrl.ts
+++ b/public/app/features/org/org_users_ctrl.ts
@@ -1,8 +1,8 @@
///
-import angular from 'angular';
+import config from 'app/core/config';
import _ from 'lodash';
-import coreModule from '../../core/core_module';
+import coreModule from 'app/core/core_module';
export class OrgUsersCtrl {
@@ -10,6 +10,7 @@ export class OrgUsersCtrl {
users: any;
pendingInvites: any;
editor: any;
+ showInviteUI: boolean;
/** @ngInject */
constructor(private $scope, private $http, private backendSrv) {
@@ -17,8 +18,10 @@ export class OrgUsersCtrl {
loginOrEmail: '',
role: 'Viewer',
};
+
this.get();
this.editor = { index: 0 };
+ this.showInviteUI = config.disableLoginForm === false;
}
get() {
@@ -50,17 +53,13 @@ export class OrgUsersCtrl {
removeUserConfirmed(user) {
this.backendSrv.delete('/api/org/users/' + user.userId)
- .then(() => {
- this.get();
- });
+ .then(this.get.bind(this));
}
revokeInvite(invite, evt) {
evt.stopPropagation();
this.backendSrv.patch('/api/org/invites/' + invite.code + '/revoke')
- .then(() => {
- this.get();
- });
+ .then(this.get.bind(this));
}
copyInviteToClipboard(evt) {
@@ -69,17 +68,18 @@ export class OrgUsersCtrl {
openInviteModal() {
var modalScope = this.$scope.$new();
- modalScope.invitesSent = function() {
- this.get();
- };
+ modalScope.invitesSent = this.get.bind(this);
+
+ var src = this.showInviteUI
+ ? 'public/app/features/org/partials/invite.html'
+ : 'public/app/features/org/partials/add_user.html';
this.$scope.appEvent('show-modal', {
- src: 'public/app/features/org/partials/invite.html',
+ src: src,
modalClass: 'invite-modal',
scope: modalScope
});
}
-
}
coreModule.controller('OrgUsersCtrl', OrgUsersCtrl);
diff --git a/public/app/features/org/partials/add_user.html b/public/app/features/org/partials/add_user.html
new file mode 100644
index 00000000000..53fe7884df9
--- /dev/null
+++ b/public/app/features/org/partials/add_user.html
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+ Add existing Grafana users to the organization
+ {{contextSrv.user.orgName}}
+
+
+
+
+
diff --git a/public/app/features/org/partials/orgUsers.html b/public/app/features/org/partials/orgUsers.html
index 36b00b3bc03..8d348721301 100644
--- a/public/app/features/org/partials/orgUsers.html
+++ b/public/app/features/org/partials/orgUsers.html
@@ -8,7 +8,7 @@
-