Commit 970619ed by Torkel Ödegaard

Merge branch 'disable-login'

parents 4d4e165b 6f324cd7
...@@ -142,6 +142,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro ...@@ -142,6 +142,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
"ldapEnabled": setting.LdapEnabled, "ldapEnabled": setting.LdapEnabled,
"alertingEnabled": setting.AlertingEnabled, "alertingEnabled": setting.AlertingEnabled,
"googleAnalyticsId": setting.GoogleAnalyticsId, "googleAnalyticsId": setting.GoogleAnalyticsId,
"disableLoginForm": setting.DisableLoginForm,
"buildInfo": map[string]interface{}{ "buildInfo": map[string]interface{}{
"version": setting.BuildVersion, "version": setting.BuildVersion,
"commit": setting.BuildCommit, "commit": setting.BuildCommit,
......
...@@ -94,6 +94,10 @@ func LoginApiPing(c *middleware.Context) { ...@@ -94,6 +94,10 @@ func LoginApiPing(c *middleware.Context) {
} }
func LoginPost(c *middleware.Context, cmd dtos.LoginCommand) Response { func LoginPost(c *middleware.Context, cmd dtos.LoginCommand) Response {
if setting.DisableLoginForm {
return ApiError(401, "Login is disabled", nil)
}
authQuery := login.LoginUserQuery{ authQuery := login.LoginUserQuery{
Username: cmd.User, Username: cmd.User,
Password: cmd.Password, Password: cmd.Password,
......
...@@ -38,6 +38,10 @@ func AddOrgInvite(c *middleware.Context, inviteDto dtos.AddInviteForm) Response ...@@ -38,6 +38,10 @@ func AddOrgInvite(c *middleware.Context, inviteDto dtos.AddInviteForm) Response
if err != m.ErrUserNotFound { if err != m.ErrUserNotFound {
return ApiError(500, "Failed to query db for existing user check", err) 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 { } else {
return inviteExistingUserToOrg(c, userQuery.Result, &inviteDto) return inviteExistingUserToOrg(c, userQuery.Result, &inviteDto)
} }
......
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import angular from 'angular'; import config from 'app/core/config';
import _ from 'lodash'; import _ from 'lodash';
import coreModule from '../../core/core_module'; import coreModule from 'app/core/core_module';
export class OrgUsersCtrl { export class OrgUsersCtrl {
...@@ -10,6 +10,7 @@ export class OrgUsersCtrl { ...@@ -10,6 +10,7 @@ export class OrgUsersCtrl {
users: any; users: any;
pendingInvites: any; pendingInvites: any;
editor: any; editor: any;
showInviteUI: boolean;
/** @ngInject */ /** @ngInject */
constructor(private $scope, private $http, private backendSrv) { constructor(private $scope, private $http, private backendSrv) {
...@@ -17,8 +18,10 @@ export class OrgUsersCtrl { ...@@ -17,8 +18,10 @@ export class OrgUsersCtrl {
loginOrEmail: '', loginOrEmail: '',
role: 'Viewer', role: 'Viewer',
}; };
this.get(); this.get();
this.editor = { index: 0 }; this.editor = { index: 0 };
this.showInviteUI = config.disableLoginForm === false;
} }
get() { get() {
...@@ -50,17 +53,13 @@ export class OrgUsersCtrl { ...@@ -50,17 +53,13 @@ export class OrgUsersCtrl {
removeUserConfirmed(user) { removeUserConfirmed(user) {
this.backendSrv.delete('/api/org/users/' + user.userId) this.backendSrv.delete('/api/org/users/' + user.userId)
.then(() => { .then(this.get.bind(this));
this.get();
});
} }
revokeInvite(invite, evt) { revokeInvite(invite, evt) {
evt.stopPropagation(); evt.stopPropagation();
this.backendSrv.patch('/api/org/invites/' + invite.code + '/revoke') this.backendSrv.patch('/api/org/invites/' + invite.code + '/revoke')
.then(() => { .then(this.get.bind(this));
this.get();
});
} }
copyInviteToClipboard(evt) { copyInviteToClipboard(evt) {
...@@ -69,17 +68,18 @@ export class OrgUsersCtrl { ...@@ -69,17 +68,18 @@ export class OrgUsersCtrl {
openInviteModal() { openInviteModal() {
var modalScope = this.$scope.$new(); var modalScope = this.$scope.$new();
modalScope.invitesSent = function() { modalScope.invitesSent = this.get.bind(this);
this.get();
}; var src = this.showInviteUI
? 'public/app/features/org/partials/invite.html'
: 'public/app/features/org/partials/add_user.html';
this.$scope.appEvent('show-modal', { this.$scope.appEvent('show-modal', {
src: 'public/app/features/org/partials/invite.html', src: src,
modalClass: 'invite-modal', modalClass: 'invite-modal',
scope: modalScope scope: modalScope
}); });
} }
} }
coreModule.controller('OrgUsersCtrl', OrgUsersCtrl); coreModule.controller('OrgUsersCtrl', OrgUsersCtrl);
<div class="modal-body" ng-controller="UserInviteCtrl" ng-init="init()">
<div class="modal-header">
<h2 class="modal-header-title">
Add Users
</h2>
<a class="modal-header-close" ng-click="dismiss();">
<i class="fa fa-remove"></i>
</a>
</div>
<div class="modal-content">
<div class="modal-tagline p-b-2">
Add existing Grafana users to the organization
<span class="highlight-word">{{contextSrv.user.orgName}}</span>
</div>
<form name="inviteForm">
<div class="gf-form-group">
<div class="gf-form-inline" ng-repeat="invite in invites">
<div class="gf-form max-width-21">
<span class="gf-form-label">Email or Username</span>
<input type="text" ng-model="invite.loginOrEmail" required class="gf-form-input" placeholder="email@test.com">
</div>
<div class="gf-form max-width-10">
<span class="gf-form-label">Role</span>
<select ng-model="invite.role" class="gf-form-input" ng-options="f for f in ['Viewer', 'Editor', 'Read Only Editor', 'Admin']">
</select>
</div>
<div class="gf-form gf-size-auto">
<a class="gf-form-label pointer" tabindex="1" ng-click="removeInvite(invite)">
<i class="fa fa-remove"></i>
</a>
</div>
</div>
</div>
<div class="gf-form-inline gf-form-group">
<div class="gf-form">
<a class="btn btn-inverse btn-small" ng-click="addInvite()">
<i class="fa fa-plus"></i>
Add another
</a>
</div>
</div>
<div class="gf-form-button-row">
<button type="submit" class="btn btn-success" ng-click="sendInvites();">Add Users</button>
<a class="btn-text" ng-click="dismiss()">Cancel</a>
</div>
<div class="clearfix"></div>
</form>
</div>
</div>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<div class="page-header-tabs"> <div class="page-header-tabs">
<button class="btn btn-success" ng-click="ctrl.openInviteModal()"> <button class="btn btn-success" ng-click="ctrl.openInviteModal()">
<i class="fa fa-plus"></i> <i class="fa fa-plus"></i>
Add or Invite Add <span ng-show="ctrl.showInviteUI"> or Invite</span>
</button> </button>
<ul class="gf-tabs"> <ul class="gf-tabs">
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
Users ({{ctrl.users.length}}) Users ({{ctrl.users.length}})
</a> </a>
</li> </li>
<li class="gf-tabs-item"> <li class="gf-tabs-item" ng-show="ctrl.showInviteUI">
<a class="gf-tabs-link" ng-click="ctrl.editor.index = 1" ng-class="{active: ctrl.editor.index === 1}"> <a class="gf-tabs-link" ng-click="ctrl.editor.index = 1" ng-class="{active: ctrl.editor.index === 1}">
Pending Invitations ({{ctrl.pendingInvites.length}}) Pending Invitations ({{ctrl.pendingInvites.length}})
</a> </a>
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
</table> </table>
</div> </div>
<div ng-if="ctrl.editor.index === 1" > <div ng-if="ctrl.editor.index === 1 && ctrl.showInviteUI">
<table class="filter-table form-inline"> <table class="filter-table form-inline">
<thead> <thead>
<tr> <tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment