Skip to content

Commit

Permalink
Check user is logged-in before changing the email address (#4321)
Browse files Browse the repository at this point in the history
  • Loading branch information
nono authored Feb 8, 2024
2 parents 839378b + 2ed654a commit 57b3117
Show file tree
Hide file tree
Showing 5 changed files with 356 additions and 351 deletions.
4 changes: 1 addition & 3 deletions assets/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -779,9 +779,7 @@ msgid "Mail Update Email Intro 1"
msgstr "Hello %s,"

msgid "Mail Update Email Intro 2"
msgstr ""
"You asked to change your email address. "
"If you didn't initiate this request, please contact us by replying directly to this email."
msgstr "You asked to change the email address of your Cozy."

msgid "Mail Update Email Button instruction"
msgstr "Click on the following button to confirm the new address."
Expand Down
4 changes: 1 addition & 3 deletions assets/locales/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,7 @@ msgid "Mail Update Email Intro 1"
msgstr "Bonjour %s,"

msgid "Mail Update Email Intro 2"
msgstr ""
"Vous avez demandé à changer votre adresse email. Si ce n'est pas le cas, "
"contactez-nous en réponse à cet email."
msgstr "Vous avez demandé à changer l'adresse email de votre Cozy."

msgid "Mail Update Email Button instruction"
msgstr "Cliquez sur le bouton suivant pour valider votre changement d'adresse email."
Expand Down
2 changes: 2 additions & 0 deletions assets/mails/update_email.mjml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
</mj-text>
<mj-text mj-class="content-medium">
{{t "Mail Update Email Intro 1" .PublicName}}<br />
</mj-text>
<mj-text mj-class="content-medium">
{{t "Mail Update Email Intro 2"}}
</mj-text>
<mj-text mj-class="content-medium">
Expand Down
9 changes: 8 additions & 1 deletion web/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"net/http"
"net/url"
"strings"

"github.com/cozy/cozy-stack/model/feature"
Expand Down Expand Up @@ -167,9 +168,15 @@ func (h *HTTPHandler) deleteEmail(c echo.Context) error {
}

func (h *HTTPHandler) getEmailConfirmation(c echo.Context) error {
tok := c.QueryParam("token")
inst := middlewares.GetInstance(c)
if !middlewares.IsLoggedIn(c) {
u := inst.PageURL("/auth/login", url.Values{
"redirect": {inst.FromURL(c.Request().URL)},
})
return c.Redirect(http.StatusSeeOther, u)
}

tok := c.QueryParam("token")
settingsURL := inst.SubDomain("settings").String()

err := h.svc.ConfirmEmailUpdate(inst, tok)
Expand Down
Loading

0 comments on commit 57b3117

Please sign in to comment.