π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Merge remote-tracking branch 'origin/main' into ott_email_one_click
Neeraj Gupta9148916d88d7
diff --cc server/ente/user.goindex 8b207712d9,8b207712d9..b5c436a11f--- a/server/ente/user.go+++ b/server/ente/user.go@@@ -1,7 -1,7 +1,8 @@@package enteconst (-- OTTTemplate = "ott.html"++ OTTTemplate = "ott.html"++ OTTMobileTemplate = "ott_mobile.html"ChangeEmailOTTTemplate = "ott_change_email.html"EmailChangedTemplate = "email_changed.html"@@@ -30,7 -30,7 +31,9 @@@ type User structtype SendOTTRequest struct {Email string `json:"email"`Client string `json:"client"`-- Purpose string `json:"purpose"`++ Purpose string `json:"purpose"++ // Mobile indicates whether the request is coming from a mobile client`++ Mobile bool `json:"mobile"`}// EmailVerificationRequest represents an email verification requestdiff --cc server/mail-templates/ott.htmlindex 0000000000,0c671a53c0..4b70e035bcmode 000000,100644..100644--- a/server/mail-templates/ott.html+++ b/server/mail-templates/ott.html@@@ -1,0 -1,126 +1,126 @@@+ <!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) {++ 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 {- max-width: auto;++ 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: 10px;++ padding: 30px;++ }++++ img {++ max-width: 100%;++ height: auto;++ }++++ a {++ color: #0055d4;++ }++++ a:hover {++ color: #111;+ }-}+-.footer-icons {- padding: 4px !important;- width: 24px !important;-}++ @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: 30px; max-width: 525px; margin: 0 auto; border-radius: 5px; font-size: 16px">- <p style="text-align: center;">Enter this code to complete verification:</p>- <center>- <div style="background-color:#DEDEDE; border-radius:6px; color:#00b33c; display:inline-block; letter-spacing:4px; padding:12px 18px 12px 18px; text-align:center; font-size:24px; font-weight: bold;" target="_blank">{{.VerificationCode}}</div>- </center>- <hr style="margin-top: 24px; margin-bottom: 24px" />- <p style="text-align: center; font-size: 14px;">Need help? Contact us at <a href="mailto:[email protected]" style=" color:#00b33c; display:inline-block">[email protected]</a>.</p></p>++<div class="gutter" style="padding: 4px"> </div>++<div class="wrap" style="background-color: rgb(255, 255, 255); padding: 30px; max-width: 525px; margin: 0 auto; border-radius: 5px; font-size: 16px">++ <p style="text-align: center;">Enter this code to complete verification:</p>++ <center>++ <div style="background-color:#DEDEDE; border-radius:6px; color:#00b33c; display:inline-block; letter-spacing:4px; padding:12px 18px 12px 18px; text-align:center; font-size:24px; font-weight: bold;" target="_blank">{{.VerificationCode}}</div>++ </center>++ <hr style="margin-top: 24px; margin-bottom: 24px" />++ <p style="text-align: center; font-size: 14px;">Need help? Contact us at <a href="mailto:[email protected]" style=" color:#00b33c; display:inline-block">[email protected]</a>.</p></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>- <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>++ <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 --cc server/mail-templates/ott_mobile.htmlindex 16557932c0,0000000000..16557932c0mode 100644,000000..100644--- a/server/mail-templates/ott_mobile.html+++ b/server/mail-templates/ott_mobile.htmldiff --cc server/pkg/api/user.goindex c62613ccb7,2f588da6b9..8e791ad55f--- a/server/pkg/api/user.go+++ b/server/pkg/api/user.go@@@ -40,7 -40,7 +40,7 @@@ func (h *UserHandler) SendOTT(c *gin.Cohandler.Error(c, stacktrace.Propagate(ente.ErrBadRequest, "Email id is missing"))return}-- err := h.UserController.SendEmailOTT(c, email, request.Purpose)++ err := h.UserController.SendEmailOTT(c, email, request.Purpose, request.Mobile)if err != nil {handler.Error(c, stacktrace.Propagate(err, ""))returndiff --cc server/pkg/controller/user/userauth.goindex 8d66023e98,ae20dff124..8a516de595--- a/server/pkg/controller/user/userauth.go+++ b/server/pkg/controller/user/userauth.go@@@ -82,24 -82,9 +82,9 @@@ func hardcodedOTTForEmail(hardCodedOTT}// SendEmailOTT generates and sends an OTT to the provided email address--func (c *UserController) SendEmailOTT(context *gin.Context, email string, purpose string) error {- if purpose == ente.ChangeEmailOTTPurpose {- if err := c.isEmailAlreadyUsed(email); err != nil {- return err- }- }- if purpose == ente.SignUpOTTPurpose || purpose == ente.LoginOTTPurpose {- isComplete, err := c.isSignUpComplete(email)- if err != nil {- return stacktrace.Propagate(err, "")- }- if isComplete && purpose == ente.SignUpOTTPurpose {- return stacktrace.Propagate(ente.ErrUserAlreadyRegistered, "user has already completed sign up process")- }-- if !isComplete && purpose == ente.LoginOTTPurpose {- return stacktrace.Propagate(ente.ErrUserNotRegistered, "user has not completed sign up process")- }++func (c *UserController) SendEmailOTT(context *gin.Context, email string, purpose string, mobile bool) error {+ if err := c.validateSendOTT(context, email, purpose); err != nil {+ return err}ott, err := random.GenerateSixDigitOtp()if err != nil {@@@ -134,7 -119,7 +119,7 @@@return stacktrace.Propagate(err, "")}log.Info("Added ott for " + emailHash + ": " + ott)-- err = emailOTT(email, ott, purpose)++ err = emailOTT(email, ott, purpose, mobile)if err != nil {return stacktrace.Propagate(err, "")}@@@ -362,12 -383,12 +383,16 @@@ func (c *UserController) TerminateSessireturn stacktrace.Propagate(c.UserAuthRepo.RemoveToken(userID, token), "")}--func emailOTT(to string, ott string, purpose string) error {++func emailOTT(to string, ott string, purpose string, mobile bool) error {var templateName stringif purpose == ente.ChangeEmailOTTPurpose {templateName = ente.ChangeEmailOTTTemplate} else {-- templateName = ente.OTTTemplate++ if mobile {++ templateName = ente.OTTMobileTemplate++ } else {++ templateName = ente.OTTTemplate++ }}subject := fmt.Sprintf("Verification code: %s", ott)err := emailUtil.SendTemplatedEmail([]string{to}, "Ente", "[email protected]",