Add fullName to magic link form
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -61,6 +61,7 @@ type (
|
||||
}
|
||||
|
||||
SendMagicLinkRequest struct {
|
||||
FullName string
|
||||
Email mail.Addr
|
||||
URLPath string
|
||||
OrganizationID gid.GID
|
||||
@@ -74,6 +75,7 @@ type (
|
||||
}
|
||||
|
||||
MagicLinkData struct {
|
||||
FullName string `json:"fullName"`
|
||||
Email mail.Addr `json:"email"`
|
||||
Continue *string `json:"continue"`
|
||||
}
|
||||
@@ -595,6 +597,7 @@ func (s AuthService) SendMagicLink(ctx context.Context, req *SendMagicLinkReques
|
||||
TokenTypeMagicLink,
|
||||
s.magicLinkTokenValidity,
|
||||
MagicLinkData{
|
||||
FullName: req.FullName,
|
||||
Email: req.Email,
|
||||
Continue: req.Continue,
|
||||
},
|
||||
@@ -616,20 +619,9 @@ func (s AuthService) SendMagicLink(ctx context.Context, req *SendMagicLinkReques
|
||||
return fmt.Errorf("cannot insert token: %w", err)
|
||||
}
|
||||
|
||||
fullName := req.Email.Username()
|
||||
identity := &coredata.Identity{}
|
||||
fullName := req.FullName
|
||||
organization := &coredata.Organization{}
|
||||
|
||||
if err := identity.LoadByEmail(ctx, tx, req.Email); err == nil {
|
||||
if identity.FullName != "" {
|
||||
fullName = identity.FullName
|
||||
}
|
||||
} else {
|
||||
if !errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return fmt.Errorf("cannot load identity: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := organization.LoadByID(ctx, tx, coredata.NewNoScope(), req.OrganizationID); err != nil {
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
@@ -728,6 +720,10 @@ func (s AuthService) OpenSessionWithMagicLink(ctx context.Context, tokenString s
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if identity.FullName == "" {
|
||||
identity.FullName = payload.Data.FullName
|
||||
}
|
||||
|
||||
if err := identity.Insert(ctx, tx); err != nil {
|
||||
return fmt.Errorf("cannot create identity: %w", err)
|
||||
}
|
||||
|
||||
@@ -611,6 +611,7 @@ type DocumentAccess implements Node {
|
||||
}
|
||||
|
||||
input SendMagicLinkInput {
|
||||
fullName: String!
|
||||
email: EmailAddr!
|
||||
continue: String
|
||||
}
|
||||
|
||||
@@ -2033,6 +2033,7 @@ type DocumentAccess implements Node {
|
||||
}
|
||||
|
||||
input SendMagicLinkInput {
|
||||
fullName: String!
|
||||
email: EmailAddr!
|
||||
continue: String
|
||||
}
|
||||
@@ -9515,13 +9516,20 @@ func (ec *executionContext) unmarshalInputSendMagicLinkInput(ctx context.Context
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"email", "continue"}
|
||||
fieldsInOrder := [...]string{"fullName", "email", "continue"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch k {
|
||||
case "fullName":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fullName"))
|
||||
data, err := ec.unmarshalNString2string(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.FullName = data
|
||||
case "email":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
|
||||
data, err := ec.unmarshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
|
||||
|
||||
@@ -214,6 +214,7 @@ type RequestTrustCenterFileAccessInput struct {
|
||||
}
|
||||
|
||||
type SendMagicLinkInput struct {
|
||||
FullName string `json:"fullName"`
|
||||
Email mail.Addr `json:"email"`
|
||||
Continue *string `json:"continue,omitempty"`
|
||||
}
|
||||
|
||||
@@ -193,6 +193,7 @@ func (r *mutationResolver) SendMagicLink(ctx context.Context, input types.SendMa
|
||||
}
|
||||
|
||||
req := &iam.SendMagicLinkRequest{
|
||||
FullName: input.FullName,
|
||||
Email: input.Email,
|
||||
CompliancePageID: &trustCenter.ID,
|
||||
OrganizationID: trustCenter.OrganizationID,
|
||||
|
||||
Reference in New Issue
Block a user