Chore: Add tempuser service (#53325)

* Chore: Add tempuser service

* Add implementation

* Fix linter; Inject tempUser into wire and HTTPServer

* Fix errors
This commit is contained in:
Kat Yang
2022-08-12 12:13:23 -04:00
committed by GitHub
parent 101c087fc7
commit 943cdea855
7 changed files with 96 additions and 4 deletions
+5 -3
View File
@@ -80,6 +80,7 @@ import (
"github.com/grafana/grafana/pkg/services/star"
"github.com/grafana/grafana/pkg/services/store"
"github.com/grafana/grafana/pkg/services/teamguardian"
tempUser "github.com/grafana/grafana/pkg/services/temp_user"
"github.com/grafana/grafana/pkg/services/thumbs"
"github.com/grafana/grafana/pkg/services/updatechecker"
"github.com/grafana/grafana/pkg/services/user"
@@ -176,6 +177,7 @@ type HTTPServer struct {
kvStore kvstore.KVStore
secretsMigrator secrets.Migrator
userService user.Service
tempUserService tempUser.Service
}
type ServerOptions struct {
@@ -210,9 +212,8 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
teamsPermissionsService accesscontrol.TeamPermissionsService, folderPermissionsService accesscontrol.FolderPermissionsService,
dashboardPermissionsService accesscontrol.DashboardPermissionsService, dashboardVersionService dashver.Service,
starService star.Service, csrfService csrf.Service, coremodels *registry.Base,
playlistService playlist.Service, apiKeyService apikey.Service, kvStore kvstore.KVStore,
secretsMigrator secrets.Migrator, secretsPluginManager plugins.SecretsPluginManager,
publicDashboardsApi *publicdashboardsApi.Api, userService user.Service) (*HTTPServer, error) {
playlistService playlist.Service, apiKeyService apikey.Service, kvStore kvstore.KVStore, secretsMigrator secrets.Migrator, secretsPluginManager plugins.SecretsPluginManager,
publicDashboardsApi *publicdashboardsApi.Api, userService user.Service, tempUserService tempUser.Service) (*HTTPServer, error) {
web.Env = cfg.Env
m := web.New()
@@ -300,6 +301,7 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
PublicDashboardsApi: publicDashboardsApi,
secretsMigrator: secretsMigrator,
userService: userService,
tempUserService: tempUserService,
}
if hs.Listener != nil {
hs.log.Debug("Using provided listener")
+1 -1
View File
@@ -278,7 +278,7 @@ func (hs *HTTPServer) CompleteInvite(c *models.ReqContext) response.Response {
func (hs *HTTPServer) updateTempUserStatus(ctx context.Context, code string, status models.TempUserStatus) (bool, response.Response) {
// update temp user status
updateTmpUserCmd := models.UpdateTempUserStatusCommand{Code: code, Status: status}
if err := hs.SQLStore.UpdateTempUserStatus(ctx, &updateTmpUserCmd); err != nil {
if err := hs.tempUserService.UpdateTempUserStatus(ctx, &updateTmpUserCmd); err != nil {
return false, response.Error(500, "Failed to update invite status", err)
}