Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

feat: add device, app, and IP to login email

Sven11f46fba226e
diff --git a/server/mail-templates/on_login.html b/server/mail-templates/on_login.html
index 58e424d77f..7d19d4356a 100644
--- a/server/mail-templates/on_login.html
+++ b/server/mail-templates/on_login.html
@@ -102,9 +102,23 @@
<p>Hi,</p>
<p>
We detected a new login to your Ente account at {{ .Date }} UTC.
- <br>
- <br>
- If this is not you, please reset your password. For any assistance or questions, please reply to this email.
+ </p>
+ <table>
+ <tr>
+ <td><strong>App</strong></td>
+ <td>{{ .App }}</td>
+ </tr>
+ <tr>
+ <td><strong>Device</strong></td>
+ <td>{{ .Device }}</td>
+ </tr>
+ <tr>
+ <td><strong>IP address</strong></td>
+ <td>{{ .IP }}</td>
+ </tr>
+ </table>
+ <p>
+ If this is not you, please reset your password. For any assistance or questions, please reply to this email.
</p>
</div>
<br />
diff --git a/server/pkg/controller/user/userauth.go b/server/pkg/controller/user/userauth.go
index 40a4508cbe..40c53b6b4e 100644
--- a/server/pkg/controller/user/userauth.go
+++ b/server/pkg/controller/user/userauth.go
@@ -447,14 +447,28 @@ func (c *UserController) AddTokenAndNotify(ctx context.Context, userID int64, ap
return nil
}
+ appDisplayNames := map[ente.App]string{
+ ente.Photos: "Ente Photos",
+ ente.Auth: "Ente Auth",
+ ente.Locker: "Ente Locker",
+ }
+ appName, ok := appDisplayNames[app]
+ if !ok {
+ appName = "Ente"
+ }
+ prettyUA := network.GetPrettyUA(userAgent)
+
go func() {
user, userErr := c.UserRepo.GetUserByIDInternal(userID)
if userErr != nil {
log.WithError(userErr).Error("Failed to get user")
return
}
- emailSendErr := emailUtil.SendTemplatedEmail([]string{user.Email}, "Ente", "[email protected]", emailCtrl.LoginSuccessSubject, emailCtrl.LoginSuccessTemplate, map[string]interface{}{
- "Date": t.Now().UTC().Format("02 Jan, 2006 15:04"),
+ emailSendErr := emailUtil.SendTemplatedEmail([]string{user.Email}, "Ente", "[email protected]", emailCtrl.LoginSuccessSubject, emailCtrl.LoginSuccessTemplate, map[string]interface{}{
+ "Date": t.Now().UTC().Format("02 Jan, 2006 15:04"),
+ "App": appName,
+ "Device": prettyUA,
+ "IP": ip,
}, nil)
if emailSendErr != nil {
log.WithError(emailSendErr).Error("Failed to send email")