✨ feat(auth): magic-link request + consume HTTP handlers (ADR-0028 Phase A.4) (#62)
Co-authored-by: Gabriel Radureau <arcodange@gmail.com> Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
This commit was merged in pull request #62.
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
|
||||
"dance-lessons-coach/pkg/cache"
|
||||
"dance-lessons-coach/pkg/config"
|
||||
"dance-lessons-coach/pkg/email"
|
||||
"dance-lessons-coach/pkg/greet"
|
||||
"dance-lessons-coach/pkg/middleware"
|
||||
"dance-lessons-coach/pkg/telemetry"
|
||||
@@ -252,6 +253,29 @@ func (s *Server) registerApiV1Routes(r chi.Router) {
|
||||
handler := userapi.NewAuthHandler(s.userService, s.userService, s.validator)
|
||||
r.Route("/auth", func(r chi.Router) {
|
||||
handler.RegisterRoutes(r)
|
||||
// Magic-link routes (ADR-0028 Phase A). Mounted only when the
|
||||
// userRepo also implements MagicLinkRepository (PostgresRepository does).
|
||||
if mlRepo, ok := s.userRepo.(user.MagicLinkRepository); ok {
|
||||
emailCfg := s.config.GetEmailConfig()
|
||||
sender := email.NewSMTPSender(email.SMTPConfig{
|
||||
Host: emailCfg.SMTPHost,
|
||||
Port: emailCfg.SMTPPort,
|
||||
Username: emailCfg.SMTPUsername,
|
||||
Password: emailCfg.SMTPPassword,
|
||||
UseTLS: emailCfg.SMTPUseTLS,
|
||||
Timeout: emailCfg.Timeout,
|
||||
})
|
||||
mlHandler := userapi.NewMagicLinkHandler(
|
||||
mlRepo,
|
||||
s.userService,
|
||||
s.userRepo,
|
||||
sender,
|
||||
s.config.GetMagicLinkConfig(),
|
||||
emailCfg.From,
|
||||
s.validator,
|
||||
)
|
||||
mlHandler.RegisterRoutes(r)
|
||||
}
|
||||
})
|
||||
|
||||
// Register admin routes
|
||||
|
||||
Reference in New Issue
Block a user