Skip to content

Commit d295fa4

Browse files
chore(auth): format email service methods for improved readability
1 parent 6614e94 commit d295fa4

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

pkg/auth/api/password.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ func (s *authService) InitiatePasswordSetup(
220220
}
221221
setupURL := fmt.Sprintf("%s%s?%s=%s",
222222
s.config.PasswordAuth.EmailServiceConfig.BaseURL, setupPath, setupParam, setupToken)
223-
err = s.emailService.SendPasswordSetupEmail(ctx, email, setupURL, s.config.PasswordAuth.PasswordSetupTokenTTL, localizer.GetLocale())
223+
err = s.emailService.SendPasswordSetupEmail(
224+
ctx, email, setupURL, s.config.PasswordAuth.PasswordSetupTokenTTL, localizer.GetLocale(),
225+
)
224226
if err != nil {
225227
s.logger.Error("Failed to send password setup email",
226228
zap.Error(err),
@@ -495,7 +497,9 @@ func (s *authService) InitiatePasswordReset(
495497
}
496498
resetURL := fmt.Sprintf("%s%s?%s=%s",
497499
s.config.PasswordAuth.EmailServiceConfig.BaseURL, resetPath, resetParam, resetToken)
498-
err = s.emailService.SendPasswordResetEmail(ctx, email, resetURL, s.config.PasswordAuth.PasswordResetTokenTTL, localizer.GetLocale())
500+
err = s.emailService.SendPasswordResetEmail(
501+
ctx, email, resetURL, s.config.PasswordAuth.PasswordResetTokenTTL, localizer.GetLocale(),
502+
)
499503
if err != nil {
500504
s.logger.Error("Failed to send password reset email",
501505
zap.Error(err),

pkg/auth/email/interface.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ func (s *NoOpEmailService) SendPasswordChangedNotification(ctx context.Context,
6363
return nil
6464
}
6565

66-
func (s *NoOpEmailService) SendPasswordSetupEmail(ctx context.Context, to, setupURL string, ttl time.Duration, language string) error {
66+
func (s *NoOpEmailService) SendPasswordSetupEmail(
67+
ctx context.Context, to, setupURL string, ttl time.Duration, language string,
68+
) error {
6769
s.logger.Info("No-op email service: password setup email not sent",
6870
zap.String("to", to),
6971
zap.String("setupURL", setupURL),
@@ -72,7 +74,9 @@ func (s *NoOpEmailService) SendPasswordSetupEmail(ctx context.Context, to, setup
7274
return nil
7375
}
7476

75-
func (s *NoOpEmailService) SendPasswordResetEmail(ctx context.Context, to, resetURL string, ttl time.Duration, language string) error {
77+
func (s *NoOpEmailService) SendPasswordResetEmail(
78+
ctx context.Context, to, resetURL string, ttl time.Duration, language string,
79+
) error {
7680
s.logger.Info("No-op email service: password reset email not sent",
7781
zap.String("to", to),
7882
zap.String("resetURL", resetURL),

pkg/auth/email/ses.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ func (s *SESEmailService) SendPasswordChangedNotification(ctx context.Context, t
8080
return nil
8181
}
8282

83-
func (s *SESEmailService) SendPasswordSetupEmail(ctx context.Context, to, setupURL string, ttl time.Duration, language string) error {
83+
func (s *SESEmailService) SendPasswordSetupEmail(
84+
ctx context.Context, to, setupURL string, ttl time.Duration, language string,
85+
) error {
8486
subject, body := s.renderer.RenderPasswordSetupEmail(language, setupURL, ttl)
8587

8688
err := s.sendEmail(ctx, to, subject, body)
@@ -98,7 +100,9 @@ func (s *SESEmailService) SendPasswordSetupEmail(ctx context.Context, to, setupU
98100
return nil
99101
}
100102

101-
func (s *SESEmailService) SendPasswordResetEmail(ctx context.Context, to, resetURL string, ttl time.Duration, language string) error {
103+
func (s *SESEmailService) SendPasswordResetEmail(
104+
ctx context.Context, to, resetURL string, ttl time.Duration, language string,
105+
) error {
102106
subject, body := s.renderer.RenderPasswordResetEmail(language, resetURL, ttl)
103107

104108
err := s.sendEmail(ctx, to, subject, body)

pkg/auth/email/smtp.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ func (s *SMTPEmailService) SendPasswordChangedNotification(ctx context.Context,
5959
return nil
6060
}
6161

62-
func (s *SMTPEmailService) SendPasswordSetupEmail(ctx context.Context, to, setupURL string, ttl time.Duration, language string) error {
62+
func (s *SMTPEmailService) SendPasswordSetupEmail(
63+
ctx context.Context, to, setupURL string, ttl time.Duration, language string,
64+
) error {
6365
subject, body := s.renderer.RenderPasswordSetupEmail(language, setupURL, ttl)
6466

6567
err := s.sendEmail(ctx, to, subject, body)
@@ -77,7 +79,9 @@ func (s *SMTPEmailService) SendPasswordSetupEmail(ctx context.Context, to, setup
7779
return nil
7880
}
7981

80-
func (s *SMTPEmailService) SendPasswordResetEmail(ctx context.Context, to, resetURL string, ttl time.Duration, language string) error {
82+
func (s *SMTPEmailService) SendPasswordResetEmail(
83+
ctx context.Context, to, resetURL string, ttl time.Duration, language string,
84+
) error {
8185
subject, body := s.renderer.RenderPasswordResetEmail(language, resetURL, ttl)
8286

8387
err := s.sendEmail(ctx, to, subject, body)

pkg/auth/email/templates.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ func (r *TemplateRenderer) RenderPasswordChangedEmail(language string) (subject,
212212
}
213213

214214
// RenderPasswordSetupEmail renders the password setup email template
215-
func (r *TemplateRenderer) RenderPasswordSetupEmail(language string, setupURL string, ttl time.Duration) (subject, body string) {
215+
func (r *TemplateRenderer) RenderPasswordSetupEmail(
216+
language string, setupURL string, ttl time.Duration,
217+
) (subject, body string) {
216218
template := r.getTemplateForLanguage(language).PasswordSetup
217219
if template.Subject == "" {
218220
template.Subject = defaultPasswordSetupSubject
@@ -231,7 +233,9 @@ func (r *TemplateRenderer) RenderPasswordSetupEmail(language string, setupURL st
231233
}
232234

233235
// RenderPasswordResetEmail renders the password reset email template
234-
func (r *TemplateRenderer) RenderPasswordResetEmail(language string, resetURL string, ttl time.Duration) (subject, body string) {
236+
func (r *TemplateRenderer) RenderPasswordResetEmail(
237+
language string, resetURL string, ttl time.Duration,
238+
) (subject, body string) {
235239
template := r.getTemplateForLanguage(language).PasswordReset
236240
if template.Subject == "" {
237241
template.Subject = defaultPasswordResetSubject

0 commit comments

Comments
 (0)