remove bus from loginservice (#44907)
This commit is contained in:
@@ -42,6 +42,14 @@ func (m *mockAuthInfoService) GetAuthInfo(ctx context.Context, query *models.Get
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
||||
func (m *mockAuthInfoService) SetAuthInfo(ctx context.Context, query *models.SetAuthInfoCommand) error {
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
||||
func (m *mockAuthInfoService) UpdateAuthInfo(ctx context.Context, query *models.UpdateAuthInfoCommand) error {
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
||||
func TestAdminAPIEndpoint(t *testing.T) {
|
||||
const role = models.ROLE_ADMIN
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"net/url"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
"github.com/grafana/grafana/pkg/login"
|
||||
@@ -235,7 +234,7 @@ func (hs *HTTPServer) OAuthLogin(ctx *models.ReqContext) response.Response {
|
||||
}
|
||||
|
||||
loginInfo.ExternalUser = *buildExternalUserInfo(token, userInfo, name)
|
||||
loginInfo.User, err = syncUser(ctx, &loginInfo.ExternalUser, connect)
|
||||
loginInfo.User, err = hs.SyncUser(ctx, &loginInfo.ExternalUser, connect)
|
||||
if err != nil {
|
||||
hs.handleOAuthLoginErrorWithRedirect(ctx, loginInfo, err)
|
||||
return nil
|
||||
@@ -300,8 +299,8 @@ func buildExternalUserInfo(token *oauth2.Token, userInfo *social.BasicUserInfo,
|
||||
return extUser
|
||||
}
|
||||
|
||||
// syncUser syncs a Grafana user profile with the corresponding OAuth profile.
|
||||
func syncUser(
|
||||
// SyncUser syncs a Grafana user profile with the corresponding OAuth profile.
|
||||
func (hs *HTTPServer) SyncUser(
|
||||
ctx *models.ReqContext,
|
||||
extUser *models.ExternalUserInfo,
|
||||
connect social.SocialConnector,
|
||||
@@ -313,7 +312,8 @@ func syncUser(
|
||||
ExternalUser: extUser,
|
||||
SignupAllowed: connect.IsSignupAllowed(),
|
||||
}
|
||||
if err := bus.Dispatch(ctx.Req.Context(), cmd); err != nil {
|
||||
|
||||
if err := hs.Login.UpsertUser(ctx.Req.Context(), cmd); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user