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
"ldapEnabled": setting.LdapEnabled,
"alertingEnabled": setting.AlertingEnabled,
"googleAnalyticsId": setting.GoogleAnalyticsId,
"disableLoginForm": setting.DisableLoginForm,
"buildInfo": map[string]interface{}{
"version": setting.BuildVersion,
"commit": setting.BuildCommit,
......
......@@ -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,
......
......@@ -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)
}
......
///<reference path="../../headers/common.d.ts" />
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);
<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 @@
<div class="page-header-tabs">
<button class="btn btn-success" ng-click="ctrl.openInviteModal()">
<i class="fa fa-plus"></i>
Add or Invite
Add <span ng-show="ctrl.showInviteUI"> or Invite</span>
</button>
<ul class="gf-tabs">
......@@ -17,7 +17,7 @@
Users ({{ctrl.users.length}})
</a>
</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}">
Pending Invitations ({{ctrl.pendingInvites.length}})
</a>
......@@ -52,7 +52,7 @@
</table>
</div>
<div ng-if="ctrl.editor.index === 1" >
<div ng-if="ctrl.editor.index === 1 && ctrl.showInviteUI">
<table class="filter-table form-inline">
<thead>
<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