π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
test: login success
mngshme6171dbec48f
diff --git a/server/mail-templates/on_login.html b/server/mail-templates/on_login.htmlnew file mode 100644index 0000000000..237449b469--- /dev/null+++ b/server/mail-templates/on_login.html@@ -0,0 +1,139 @@+<!DOCTYPE html>+<html>+ <meta content="text/html; charset=utf-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1,+ minimum-scale=1" />+ <style>+ body {+ background-color: #f0f1f3;+ font-family: "Helvetica Neue", "Segoe UI", Helvetica, sans-serif;+ font-size: 16px;+ line-height: 27px;+ margin: 0;+ color: #444;+ }++ pre {+ background: #f4f4f4f4;+ padding: 2px;+ }++ table {+ width: 100%;+ border: 1px solid #ddd;+ }++ table td {+ border-color: #ddd;+ padding: 5px;+ }++ .wrap {+ background-color: #fff;+ padding: 30px;+ max-width: 525px;+ margin: 0 auto;+ border-radius: 5px;+ }++ .button {+ background: #0055d4;+ border-radius: 3px;+ text-decoration: none !important;+ color: #fff !important;+ font-weight: bold;+ padding: 10px 30px;+ display: inline-block;+ }++ .button:hover {+ background: #111;+ }++ .footer {+ text-align: center;+ font-size: 12px;+ color: #888;+ }++ .footer a {+ color: #888;+ margin-right: 5px;+ }++ .gutter {+ padding: 30px;+ }++ img {+ max-width: 100%;+ height: auto;+ }++ a {+ color: #0055d4;+ }++ a:hover {+ color: #111;+ }++ @media screen and (max-width: 600px) {+ .wrap {+ max-width: auto;+ }++ .gutter {+ padding: 10px;+ }+ }++ .footer-icons {+ padding: 4px !important;+ width: 24px !important;+ }+ </style>++ <body>+ <div class="gutter" style="padding: 4px"> </div>+ <div class="wrap" style=" background-color: rgb(255, 255, 255); padding: 2px+ 30px 30px 30px; max-width: 525px; margin: 0 auto; border-radius: 5px;+ font-size: 16px; " >+ <p>Hey,</p>+ <p>+ Youβve successfully logged into your {{ .AppName }} account on {{ .Date }}.+ If you need assistance or have any questions, feel free to reach out to us anytime.+ </p>+ </div>+ <br />+ <div class="footer" style="text-align: center; font-size: 12px; color:+ rgb(136, 136, 136)" >+ <div>+ <a href="https://ente.io" target="_blank" ><img+ src="https://email-assets.ente.io/ente-green.png" style="width: 100px;+ padding: 24px" title="Ente" alt="Ente" /></a>+ </div>+ <div>+ <a href="https://fosstodon.org/@ente" target="_blank" ><img+ src="https://email-assets.ente.io/mastodon-icon.png"+ class="footer-icons" style="width: 24px; padding: 4px" title="Mastodon"+ alt="Mastodon" /></a>+ <a href="https://twitter.com/enteio" target="_blank" ><img+ src="https://email-assets.ente.io/twitter-icon.png" class="footer-icons"+ style="width: 24px; padding: 4px" title="Twitter" alt="Twitter" /></a>+ <a href="https://discord.ente.io" target="_blank" ><img+ src="https://email-assets.ente.io/discord-icon.png" class="footer-icons"+ style="width: 24px; padding: 4px" title="Discord" alt="Discord" /></a>+ <a href="https://github.com/ente-io" target="_blank" ><img+ src="https://email-assets.ente.io/github-icon.png" class="footer-icons"+ style="width: 24px; padding: 4px" title="GitHub" alt="GitHub" /></a>+ </div>+ <p>+ Ente Technologies, Inc.+ <br /> 1111B S Governors Ave 6032 Dover, DE 19904+ </p>+ <br />+ </div>+ </body>+</html>+diff --git a/server/pkg/controller/email/email_notification.go b/server/pkg/controller/email/email_notification.goindex 56bc91f013..5dd4fa27d7 100644--- a/server/pkg/controller/email/email_notification.go+++ b/server/pkg/controller/email/email_notification.go@@ -16,18 +16,25 @@ const (WebAppFirstUploadTemplate = "web_app_first_upload.html"MobileAppFirstUploadTemplate = "mobile_app_first_upload.html"FirstUploadEmailSubject = "Congratulations! π"- StorageLimitExceededMailLock = "storage_limit_exceeded_mail_lock"++ StorageLimitExceededMailLock = "storage_limit_exceeded_mail_lock"StorageLimitExceededTemplateID = "storage_limit_exceeded"StorageLimitExceededTemplate = "storage_limit_exceeded.html"- FilesCollectedTemplate = "files_collected.html"++ FilesCollectedTemplate = "files_collected.html"FilesCollectedTemplateID = "files_collected"FilesCollectedSubject = "You've got photos!"+ FilesCollectedMuteDurationInMinutes = 10+SubscriptionUpgradedTemplate = "subscription_upgraded.html"SubscriptionUpgradedSubject = "Thank you for choosing Ente!"- FilesCollectedMuteDurationInMinutes = 10+StorageLimitExceededSubject = "[Alert] You have exceeded your storage limit"ReferralSuccessfulTemplate = "successful_referral.html"ReferralSuccessfulSubject = "You've earned 10 GB on Ente! π"++ LoginSuccessSubject = "Login Successful"+ LoginSuccessTemplate = "on_login.html")type EmailNotificationController struct {diff --git a/server/pkg/controller/user/userauth.go b/server/pkg/controller/user/userauth.goindex 86828d1cee..7be990f6a5 100644--- a/server/pkg/controller/user/userauth.go+++ b/server/pkg/controller/user/userauth.go@@ -6,6 +6,7 @@ import ("errors""fmt""strings"+ t "time""github.com/ente-io/museum/pkg/utils/random"@@ -15,11 +16,13 @@ import ("github.com/spf13/viper""github.com/ente-io/museum/ente"+ emailCtrl "github.com/ente-io/museum/pkg/controller/email""github.com/ente-io/museum/pkg/utils/auth""github.com/ente-io/museum/pkg/utils/crypto"emailUtil "github.com/ente-io/museum/pkg/utils/email""github.com/ente-io/museum/pkg/utils/time""github.com/ente-io/stacktrace"+"github.com/gin-gonic/gin"log "github.com/sirupsen/logrus")@@ -93,9 +96,7 @@ func (c *UserController) SendEmailOTT(context *gin.Context, email string, purposif isComplete && purpose == ente.SignUpOTTPurpose {return stacktrace.Propagate(ente.ErrUserAlreadyRegistered, "user has already completed sign up process")}- if purpose == ente.SignUpOTTPurpose && viper.GetBool("internal.disable-registration") {- return stacktrace.Propagate(ente.ErrPermissionDenied, "registration is disabled")- }+if !isComplete && purpose == ente.LoginOTTPurpose {return stacktrace.Propagate(ente.ErrUserNotRegistered, "user has not completed sign up process")}@@ -332,6 +333,23 @@ func (c *UserController) GetActiveSessions(context *gin.Context, userID int64) (return tokens, nil}+func (c *UserController) LoginSuccess(ctx *gin.Context, userID int64, app ente.App, email string, token string, ip string, userAgent string) error {+ err := c.UserAuthRepo.AddToken(userID, app, token, ip, userAgent)++ log.Info("adding token")+ // logrus for tests+ if err == nil {+ error := emailUtil.SendTemplatedEmail([]string{email}, "Ente", "[email protected]", emailCtrl.LoginSuccessSubject, emailCtrl.LoginSuccessTemplate, map[string]interface{}{+ "AppName": app,+ "Date": t.Now(),+ }, nil)+ if error != nil {+ stacktrace.Propagate(error, "")+ }+ }+ return nil+}+// TerminateSession removes the token for a user from cache and databasefunc (c *UserController) TerminateSession(userID int64, token string) error {c.Cache.Delete(fmt.Sprintf("%s:%s", ente.Photos, token))@@ -365,7 +383,6 @@ func (c *UserController) onVerificationSuccess(context *gin.Context, email strinuserID, err := c.UserRepo.GetUserIDWithEmail(email)if err != nil {if errors.Is(err, sql.ErrNoRows) {- // Keep this check as users can still trigger ott via other means that can lead to this code pathif viper.GetBool("internal.disable-registration") {return ente.EmailAuthorizationResponse{}, stacktrace.Propagate(ente.ErrPermissionDenied, "")} else {