π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat: guard login details for ente.io emails only
Sven5ddbaa81fb90
diff --git a/server/mail-templates/on_login.html b/server/mail-templates/on_login.htmlindex 7d19d4356a..3dbb65ee53 100644--- a/server/mail-templates/on_login.html+++ b/server/mail-templates/on_login.html@@ -103,6 +103,7 @@<p>We detected a new login to your Ente account at {{ .Date }} UTC.</p>+ {{ if .App }}<table><tr><td><strong>App</strong></td>@@ -117,6 +118,7 @@<td>{{ .IP }}</td></tr></table>+ {{ end }}<p>If this is not you, please reset your password. For any assistance or questions, please reply to this email.</p>diff --git a/server/pkg/controller/user/userauth.go b/server/pkg/controller/user/userauth.goindex 40c53b6b4e..24b973fbf0 100644--- a/server/pkg/controller/user/userauth.go+++ b/server/pkg/controller/user/userauth.go@@ -447,29 +447,34 @@ func (c *UserController) AddTokenAndNotify(ctx context.Context, userID int64, apreturn 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"),- "App": appName,- "Device": prettyUA,- "IP": ip,- }, nil)+ templateData := map[string]interface{}{+ "Date": t.Now().UTC().Format("02 Jan, 2006 15:04"),+ }+ if strings.HasSuffix(emailUtil.NormalizeEmail(user.Email), "@ente.io") {+ 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"+ }+ device := "Unknown Device"+ if strings.TrimSpace(userAgent) != "" {+ device = network.GetPrettyUA(userAgent)+ }+ templateData["App"] = appName+ templateData["Device"] = device+ templateData["IP"] = ip+ }+ emailSendErr := emailUtil.SendTemplatedEmail([]string{user.Email}, "Ente", "[email protected]", emailCtrl.LoginSuccessSubject, emailCtrl.LoginSuccessTemplate, templateData, nil)if emailSendErr != nil {log.WithError(emailSendErr).Error("Failed to send email")}