Merge branch 'master' of github.com:grafana/grafana

This commit is contained in:
Torkel Ödegaard 2016-05-26 08:37:19 +02:00
commit f8a4661d05
6 changed files with 38 additions and 9 deletions

View File

@ -115,6 +115,7 @@ func Register(r *macaron.Macaron) {
r.Get("/:id", wrap(GetUserById))
r.Get("/:id/orgs", wrap(GetUserOrgList))
r.Put("/:id", bind(m.UpdateUserCommand{}), wrap(UpdateUser))
r.Post("/:id/using/:orgId", wrap(UpdateUserActiveOrg))
}, reqGrafanaAdmin)
// org information available to all users.

View File

@ -55,6 +55,13 @@ func NewReverseProxy(ds *m.DataSource, proxyPath string, targetUrl *url.URL) *ht
req.Header.Add("Authorization", util.GetBasicAuthHeader(ds.BasicAuthUser, ds.BasicAuthPassword))
}
dsAuth := req.Header.Get("X-DS-Authorization")
if len(dsAuth) > 0 {
req.Header.Del("X-DS-Authorization")
req.Header.Del("Authorization")
req.Header.Add("Authorization", dsAuth)
}
// clear cookie headers
req.Header.Del("Cookie")
req.Header.Del("Set-Cookie")

View File

@ -40,6 +40,24 @@ func UpdateUser(c *middleware.Context, cmd m.UpdateUserCommand) Response {
return handleUpdateUser(cmd)
}
//POST /api/users/:id/using/:orgId
func UpdateUserActiveOrg(c *middleware.Context) Response {
userId := c.ParamsInt64(":id")
orgId := c.ParamsInt64(":orgId")
if !validateUsingOrg(userId, orgId) {
return ApiError(401, "Not a valid organization", nil)
}
cmd := m.SetUsingOrgCommand{UserId: userId, OrgId: orgId}
if err := bus.Dispatch(&cmd); err != nil {
return ApiError(500, "Failed change active organization", err)
}
return ApiSuccess("Active organization changed")
}
func handleUpdateUser(cmd m.UpdateUserCommand) Response {
if len(cmd.Login) == 0 {
cmd.Login = cmd.Email

View File

@ -96,6 +96,11 @@ function (angular, _, coreModule, config) {
var requestIsLocal = options.url.indexOf('/') === 0;
var firstAttempt = options.retry === 0;
if (requestIsLocal && options.headers && options.headers.Authorization) {
options.headers['X-DS-Authorization'] = options.headers.Authorization;
delete options.headers.Authorization;
}
return $http(options).then(null, function(err) {
// handle unauthorized for backend requests
if (requestIsLocal && firstAttempt && err.status === 401) {

View File

@ -1,9 +1,5 @@
<div class="main">
<div class="row-fluid">
<div class="span12">
<div class="panel nospace" ng-if="panel" style="width: 100%">
<plugin-component type="panel">
</plugin-component>
</div>
</div>
<div class="panel nospace" ng-if="panel" style="width: 100%">
<plugin-component type="panel">
</plugin-component>
</div>
<div class="clearfix"></div>

View File

@ -39,7 +39,8 @@
var canvas = page.evaluate(function() {
if (!window.angular) { return false; }
var body = window.angular.element(document.body);
if (!body.scope) { return false; }
if (!body.injector) { return false; }
if (!body.injector()) { return false; }
var rootScope = body.injector().get('$rootScope');
if (!rootScope) {return false;}
@ -59,6 +60,7 @@
width: bb.width,
height: bb.height
};
page.render(params.png);
phantom.exit();
}