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. -->
- +
- +
diff --git a/web/marketing/pages/free-offers.html b/web/marketing/pages/free-offers.html index fca90e587..b62bdd88e 100644 --- a/web/marketing/pages/free-offers.html +++ b/web/marketing/pages/free-offers.html @@ -5,7 +5,7 @@ See LICENSE for copying information. -->
Name
-
Award Credit
+
Give Credit
Redeemable Capacity
Created
Expiration
@@ -18,7 +18,7 @@ See LICENSE for copying information. --> {{if not $defaultOffer.IsEmpty}}
{{$defaultOffer.Name}}
-
${{$defaultOffer.AwardCredit}}
+
${{$defaultOffer.InviteeCredit}}
{{$defaultOffer.RedeemableCap}}
{{printf "%.10s" $defaultOffer.CreatedAt}}
{{printf "%.10s" $defaultOffer.ExpiresAt}}
@@ -32,7 +32,7 @@ See LICENSE for copying information. --> {{if not $currentOffer.IsEmpty}}
{{$currentOffer.Name}}
-
${{$currentOffer.AwardCredit}}
+
${{$currentOffer.InviteeCredit}}
{{$currentOffer.RedeemableCap}}
{{printf "%.10s" $currentOffer.CreatedAt}}
{{printf "%.10s" $currentOffer.ExpiresAt}}
@@ -50,7 +50,7 @@ See LICENSE for copying information. --> {{range .FreeCredits.Done}}
{{.Name}}
-
${{.AwardCredit}}
+
${{.InviteeCredit}}
{{.RedeemableCap}}
{{printf "%.10s" .CreatedAt}}
{{printf "%.10s" .ExpiresAt}}
diff --git a/web/satellite/src/api/users.ts b/web/satellite/src/api/users.ts index 13dc002d2..b2c6a28cd 100644 --- a/web/satellite/src/api/users.ts +++ b/web/satellite/src/api/users.ts @@ -97,7 +97,7 @@ export async function forgotPasswordRequest(email: string): Promise> { +export async function createUserRequest(user: User, password: string, secret: string, refUserId?: string): Promise> { let result: RequestResponse = new RequestResponse(); let response = await apolloManager.mutate( @@ -112,6 +112,7 @@ export async function createUserRequest(user: User, password: string, secret: st shortName: "${user.shortName}", partnerId: "${user.partnerId}", }, + refUserId: "${refUserId || ""}", secret: "${secret}", ){email, id} }` diff --git a/web/satellite/src/views/register/Register.vue b/web/satellite/src/views/register/Register.vue index 7172300e7..08664bef0 100644 --- a/web/satellite/src/views/register/Register.vue +++ b/web/satellite/src/views/register/Register.vue @@ -38,6 +38,7 @@ private isTermsAcceptedError: boolean = false; private secret: string = ''; private partnerId: string = ''; + private refUserId: string = ''; private loadingClassName: string = LOADING_CLASSES.LOADING_OVERLAY; mounted(): void { @@ -49,7 +50,7 @@ let referralIds = ids ? JSON.parse(atob(ids)) : undefined; if (referralIds) { this.$data.partnerId = referralIds.partnerId; - this.$data.referrerId = referralIds.userId; + this.$data.refUserId = referralIds.userId; } } @@ -124,7 +125,7 @@ } private async createUser(): Promise { let user = new User(this.fullName.trim(), this.shortName.trim(), this.email.trim(), this.partnerId); - let response = await createUserRequest(user, this.password, this.secret); + let response = await createUserRequest(user, this.password, this.secret, this.refUserId); if (!response.isSuccess) { this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, response.errorMessage); this.loadingClassName = LOADING_CLASSES.LOADING_OVERLAY;