Extract magic link handler and verify email

Move MagicLinkHandler out of oidc_handler.go. Completing a
magic link for an existing identity now marks the address
verified, matching OIDC behavior.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-07-28 15:10:16 +02:00
parent d08e4c3314
commit 6e11886365
3 changed files with 183 additions and 143 deletions

View File

@@ -726,6 +726,13 @@ func (s AuthService) OpenSessionWithMagicLink(ctx context.Context, tokenString s
} else {
return fmt.Errorf("cannot load identity by email: %w", err)
}
} else if !identity.EmailAddressVerified {
identity.EmailAddressVerified = true
identity.UpdatedAt = now
if err := identity.Update(ctx, tx); err != nil {
return fmt.Errorf("cannot update identity: %w", err)
}
}
session = coredata.NewRootSession(identity.ID, coredata.AuthMethodMagicLink, s.sessionDuration)