diff --git a/satellite/console/consoleweb/consoleql/mutation.go b/satellite/console/consoleweb/consoleql/mutation.go index 4e42e2d7f..b77513a82 100644 --- a/satellite/console/consoleweb/consoleql/mutation.go +++ b/satellite/console/consoleweb/consoleql/mutation.go @@ -61,6 +61,8 @@ const ( FieldNewPassword = "newPassword" // Secret is a field name for registration token for user creation during Vanguard release Secret = "secret" + // ReferrerUserID is a field name for passing referrer's user id + ReferrerUserID = "referrerUserID" ) // rootMutation creates mutation for graphql populated by AccountsClient @@ -77,11 +79,15 @@ func rootMutation(log *zap.Logger, service *console.Service, mailService *mailse Secret: &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.String), }, + ReferrerUserID: &graphql.ArgumentConfig{ + Type: graphql.String, + }, }, // creates user and company from input params and returns userID if succeed Resolve: func(p graphql.ResolveParams) (interface{}, error) { input, _ := p.Args[InputArg].(map[string]interface{}) secretInput, _ := p.Args[Secret].(string) + refUserID, _ := p.Args[ReferrerUserID].(string) offerType := rewards.FreeCredit @@ -96,7 +102,7 @@ func rootMutation(log *zap.Logger, service *console.Service, mailService *mailse return nil, err } - user, err := service.CreateUser(p.Context, createUser, secret) + user, err := service.CreateUser(p.Context, createUser, secret, refUserID) if err != nil { log.Error("register: failed to create account", zap.String("rawSecret", secretInput), diff --git a/satellite/console/consoleweb/consoleql/mutation_test.go b/satellite/console/consoleweb/consoleql/mutation_test.go index 68b976b69..b5bc08838 100644 --- a/satellite/console/consoleweb/consoleql/mutation_test.go +++ b/satellite/console/consoleweb/consoleql/mutation_test.go @@ -79,11 +79,12 @@ func TestGrapqhlMutation(t *testing.T) { }, Password: "123a123", } + refUserID := "" regToken, err := service.CreateRegToken(ctx, 1) require.NoError(t, err) - rootUser, err := service.CreateUser(ctx, createUser, regToken.Secret) + rootUser, err := service.CreateUser(ctx, createUser, regToken.Secret, refUserID) require.NoError(t, err) require.Equal(t, createUser.PartnerID, rootUser.PartnerID.String()) @@ -350,7 +351,7 @@ func TestGrapqhlMutation(t *testing.T) { Email: "u1@mail.test", }, Password: "123a123", - }, regTokenUser1.Secret) + }, regTokenUser1.Secret, refUserID) require.NoError(t, err) t.Run("Activation", func(t *testing.T) { @@ -376,7 +377,7 @@ func TestGrapqhlMutation(t *testing.T) { Email: "u2@mail.test", }, Password: "123a123", - }, regTokenUser2.Secret) + }, regTokenUser2.Secret, refUserID) require.NoError(t, err) t.Run("Activation", func(t *testing.T) { diff --git a/satellite/console/consoleweb/consoleql/query_test.go b/satellite/console/consoleweb/consoleql/query_test.go index fde0bcc4e..cdff514dc 100644 --- a/satellite/console/consoleweb/consoleql/query_test.go +++ b/satellite/console/consoleweb/consoleql/query_test.go @@ -67,11 +67,12 @@ func TestGraphqlQuery(t *testing.T) { }, Password: "123a123", } + refUserID := "" regToken, err := service.CreateRegToken(ctx, 2) require.NoError(t, err) - rootUser, err := service.CreateUser(ctx, createUser, regToken.Secret) + rootUser, err := service.CreateUser(ctx, createUser, regToken.Secret, refUserID) require.NoError(t, err) t.Run("Activation", func(t *testing.T) { @@ -188,7 +189,7 @@ func TestGraphqlQuery(t *testing.T) { Email: "muu1@mail.test", }, Password: "123a123", - }, regTokenUser1.Secret) + }, regTokenUser1.Secret, refUserID) require.NoError(t, err) t.Run("Activation", func(t *testing.T) { @@ -214,7 +215,7 @@ func TestGraphqlQuery(t *testing.T) { Email: "muu2@mail.test", }, Password: "123a123", - }, regTokenUser2.Secret) + }, regTokenUser2.Secret, refUserID) require.NoError(t, err) t.Run("Activation", func(t *testing.T) { @@ -426,7 +427,7 @@ func TestGraphqlQuery(t *testing.T) { Email: "user@mail.test", }, Password: "123a123", - }, regToken.Secret) + }, regToken.Secret, refUserID) require.NoError(t, err) @@ -466,7 +467,7 @@ func TestGraphqlQuery(t *testing.T) { Email: "user1@mail.test", }, Password: "123a123", - }, regToken.Secret) + }, regToken.Secret, refUserID) require.NoError(t, err) diff --git a/satellite/console/service.go b/satellite/console/service.go index 3021d5afd..6220c4bdb 100644 --- a/satellite/console/service.go +++ b/satellite/console/service.go @@ -93,7 +93,7 @@ func NewService(log *zap.Logger, signer Signer, store DB, rewards rewards.DB, pm } // CreateUser gets password hash value and creates new inactive User -func (s *Service) CreateUser(ctx context.Context, user CreateUser, tokenSecret RegistrationSecret) (u *User, err error) { +func (s *Service) CreateUser(ctx context.Context, user CreateUser, tokenSecret RegistrationSecret, refUserID string) (u *User, err error) { defer mon.Task()(&ctx)(&err) if err := user.IsValid(); err != nil { return nil, err diff --git a/web/marketing/pages/free-offers-modal.html b/web/marketing/pages/free-offers-modal.html index 2491f3bb2..8857ddc52 100644 --- a/web/marketing/pages/free-offers-modal.html +++ b/web/marketing/pages/free-offers-modal.html @@ -29,11 +29,11 @@ See LICENSE for copying information. -->