Commit f8a4661d by Torkel Ödegaard

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

parents 1060eeb1 dd494e64
......@@ -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.
......
......@@ -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")
......
......@@ -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
......
......@@ -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) {
......
<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>
......@@ -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();
}
......
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