From 151fe240fcdf9b09434a18d4756c0b2ce22b674b Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Wed, 12 Jun 2019 12:47:38 +0100 Subject: [PATCH] OAuth: Fix for wrong user token updated on OAuth refresh in DS proxy (#17541) --- pkg/api/pluginproxy/ds_proxy.go | 2 +- pkg/services/sqlstore/user_auth.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/api/pluginproxy/ds_proxy.go b/pkg/api/pluginproxy/ds_proxy.go index 98fd30cc1c9..b6fc8704ced 100644 --- a/pkg/api/pluginproxy/ds_proxy.go +++ b/pkg/api/pluginproxy/ds_proxy.go @@ -354,7 +354,7 @@ func addOAuthPassThruAuth(c *m.ReqContext, req *http.Request) { // If the tokens are not the same, update the entry in the DB if token.AccessToken != authInfoQuery.Result.OAuthAccessToken { updateAuthCommand := &m.UpdateAuthInfoCommand{ - UserId: authInfoQuery.Result.Id, + UserId: authInfoQuery.Result.UserId, AuthModule: authInfoQuery.Result.AuthModule, AuthId: authInfoQuery.Result.AuthId, OAuthToken: token, diff --git a/pkg/services/sqlstore/user_auth.go b/pkg/services/sqlstore/user_auth.go index 19287b8a866..ede3ae12451 100644 --- a/pkg/services/sqlstore/user_auth.go +++ b/pkg/services/sqlstore/user_auth.go @@ -241,8 +241,8 @@ func UpdateAuthInfo(cmd *models.UpdateAuthInfoCommand) error { UserId: cmd.UserId, AuthModule: cmd.AuthModule, } - - _, err := sess.Update(authUser, cond) + upd, err := sess.Update(authUser, cond) + sqlog.Debug("Updated user_auth", "user_id", cmd.UserId, "auth_module", cmd.AuthModule, "rows", upd) return err }) }