Add fullName to magic link form

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-03-04 13:59:28 +04:00
parent b31b68f1d2
commit 9e106a8875
7 changed files with 36 additions and 16 deletions

View File

@@ -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)
}