Fix sign up and accept invite
Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
@@ -257,6 +257,19 @@ func (s *AccountService) AcceptInvitation(
|
||||
return fmt.Errorf("cannot create membership: %w", err)
|
||||
}
|
||||
|
||||
profile := &coredata.MembershipProfile{
|
||||
ID: gid.New(tenantID, coredata.MembershipProfileEntityType),
|
||||
MembershipID: membership.ID,
|
||||
FullName: identity.FullName,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
err = profile.Insert(ctx, tx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot insert profile: %w", err)
|
||||
}
|
||||
|
||||
invitation.AcceptedAt = &now
|
||||
err = invitation.Update(ctx, tx, scope)
|
||||
if err != nil {
|
||||
|
||||
@@ -425,7 +425,10 @@ func (s *OrganizationService) InviteMember(
|
||||
return fmt.Errorf("cannot parse base URL: %w", err)
|
||||
}
|
||||
|
||||
invitationURL := baseurl.WithPath("/auth/signup-from-invitation").WithQuery("token", invitationToken).MustString()
|
||||
invitationURL := baseurl.WithPath("/auth/signup-from-invitation").
|
||||
WithQuery("token", invitationToken).
|
||||
WithQuery("fullName", invitation.FullName).
|
||||
MustString()
|
||||
|
||||
subject, textBody, htmlBody, err := emails.RenderInvitation(
|
||||
s.baseURL,
|
||||
|
||||
@@ -491,6 +491,7 @@ input SignUpInput {
|
||||
input SignUpFromInvitationInput {
|
||||
token: String!
|
||||
password: String!
|
||||
fullName: String!
|
||||
}
|
||||
|
||||
input ForgotPasswordInput {
|
||||
|
||||
@@ -2455,6 +2455,7 @@ input SignUpInput {
|
||||
input SignUpFromInvitationInput {
|
||||
token: String!
|
||||
password: String!
|
||||
fullName: String!
|
||||
}
|
||||
|
||||
input ForgotPasswordInput {
|
||||
@@ -12877,7 +12878,7 @@ func (ec *executionContext) unmarshalInputSignUpFromInvitationInput(ctx context.
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"token", "password"}
|
||||
fieldsInOrder := [...]string{"token", "password", "fullName"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -12898,6 +12899,13 @@ func (ec *executionContext) unmarshalInputSignUpFromInvitationInput(ctx context.
|
||||
return it, err
|
||||
}
|
||||
it.Password = data
|
||||
case "fullName":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fullName"))
|
||||
data, err := ec.unmarshalNString2string(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.FullName = data
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -410,6 +410,7 @@ type SignOutPayload struct {
|
||||
type SignUpFromInvitationInput struct {
|
||||
Token string `json:"token"`
|
||||
Password string `json:"password"`
|
||||
FullName string `json:"fullName"`
|
||||
}
|
||||
|
||||
type SignUpFromInvitationPayload struct {
|
||||
|
||||
@@ -440,6 +440,7 @@ func (r *mutationResolver) SignUpFromInvitation(ctx context.Context, input types
|
||||
&iam.CreateIdentityFromInvitationRequest{
|
||||
InvitationToken: input.Token,
|
||||
Password: input.Password,
|
||||
FullName: input.FullName,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user