-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_reset_success.go
More file actions
39 lines (31 loc) · 1.03 KB
/
Copy pathpassword_reset_success.go
File metadata and controls
39 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) Kopexa GmbH
// SPDX-License-Identifier: BUSL-1.1
package comms
import (
"context"
"fmt"
"github.com/kopexa-grc/comms/v2/driver"
)
// SendPasswordResetSuccessEmail sends a confirmation email to a recipient after their password has been successfully reset.
func (c *Comms) SendPasswordResetSuccessEmail(ctx context.Context, recipient Recipient) error {
if err := recipient.Validate(); err != nil {
return fmt.Errorf("invalid recipient: %w", err)
}
text, html, err := Render(recipient.Lang(), "password-reset-success", map[string]string{
"DisplayName": recipient.Name(),
})
if err != nil {
return fmt.Errorf("failed to render password reset success email: %w", err)
}
message := driver.Message{
From: c.config.From,
To: []string{recipient.String()},
Subject: Subject("password-reset-success", recipient.Lang()),
Text: text,
HTML: html,
}
if err := c.config.Driver.Send(ctx, message); err != nil {
return fmt.Errorf("failed to send password reset success email: %w", err)
}
return nil
}