浏览代码

OAuth: Fix for wrong user token updated on OAuth refresh in DS proxy (#17541)

Maxim Ivanov 6 年之前
父节点
当前提交
151fe240fc
共有 2 个文件被更改,包括 3 次插入3 次删除
  1. 1 1
      pkg/api/pluginproxy/ds_proxy.go
  2. 2 2
      pkg/services/sqlstore/user_auth.go

+ 1 - 1
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,

+ 2 - 2
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
 	})
 }