templates/user/settings/emial.tmpl: little fix on UI
- routers/user: little code format - conf/locale: update French locale
This commit is contained in:
parent
065f8d1f56
commit
1654e9ecab
8 changed files with 58 additions and 64 deletions
|
@ -351,15 +351,12 @@ func ActivateEmail(ctx *middleware.Context) {
|
|||
|
||||
// Verify code.
|
||||
if email := models.VerifyActiveEmailCode(code, email_string); email != nil {
|
||||
err := email.Activate()
|
||||
if err != nil {
|
||||
if err := email.Activate(); err != nil {
|
||||
ctx.Handle(500, "ActivateEmail", err)
|
||||
}
|
||||
|
||||
log.Trace("Email activated: %s", email.Email)
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("settings.activate_email_success"))
|
||||
|
||||
}
|
||||
|
||||
ctx.Redirect(setting.AppSubUrl + "/user/settings/email")
|
||||
|
|
|
@ -133,13 +133,12 @@ func SettingsEmails(ctx *middleware.Context) {
|
|||
ctx.Data["PageIsUserSettings"] = true
|
||||
ctx.Data["PageIsSettingsEmails"] = true
|
||||
|
||||
var err error
|
||||
ctx.Data["Emails"], err = models.GetEmailAddresses(ctx.User.Id)
|
||||
|
||||
emails, err := models.GetEmailAddresses(ctx.User.Id)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "email.GetEmailAddresses", err)
|
||||
ctx.Handle(500, "GetEmailAddresses", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Emails"] = emails
|
||||
|
||||
ctx.HTML(200, SETTINGS_EMAILS)
|
||||
}
|
||||
|
@ -149,16 +148,16 @@ func SettingsEmailPost(ctx *middleware.Context, form auth.AddEmailForm) {
|
|||
ctx.Data["PageIsUserSettings"] = true
|
||||
ctx.Data["PageIsSettingsEmails"] = true
|
||||
|
||||
var err error
|
||||
ctx.Data["Emails"], err = models.GetEmailAddresses(ctx.User.Id)
|
||||
emails, err := models.GetEmailAddresses(ctx.User.Id)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "email.GetEmailAddresses", err)
|
||||
ctx.Handle(500, "GetEmailAddresses", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Emails"] = emails
|
||||
|
||||
// Delete Email address.
|
||||
// Delete E-mail address.
|
||||
if ctx.Query("_method") == "DELETE" {
|
||||
id := com.StrTo(ctx.Query("id")).MustInt64()
|
||||
id := ctx.QueryInt64("id")
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
@ -174,7 +173,7 @@ func SettingsEmailPost(ctx *middleware.Context, form auth.AddEmailForm) {
|
|||
|
||||
// Make emailaddress primary.
|
||||
if ctx.Query("_method") == "PRIMARY" {
|
||||
id := com.StrTo(ctx.Query("id")).MustInt64()
|
||||
id := ctx.QueryInt64("id")
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
@ -189,46 +188,41 @@ func SettingsEmailPost(ctx *middleware.Context, form auth.AddEmailForm) {
|
|||
}
|
||||
|
||||
// Add Email address.
|
||||
if ctx.Req.Method == "POST" {
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, SETTINGS_EMAILS)
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, SETTINGS_EMAILS)
|
||||
return
|
||||
}
|
||||
|
||||
cleanEmail := strings.Replace(form.Email, "\n", "", -1)
|
||||
e := &models.EmailAddress{
|
||||
Uid: ctx.User.Id,
|
||||
Email: cleanEmail,
|
||||
IsActivated: !setting.Service.RegisterEmailConfirm,
|
||||
}
|
||||
|
||||
if err := models.AddEmailAddress(e); err != nil {
|
||||
if err == models.ErrEmailAlreadyUsed {
|
||||
ctx.RenderWithErr(ctx.Tr("form.email_been_used"), SETTINGS_EMAILS, &form)
|
||||
return
|
||||
}
|
||||
ctx.Handle(500, "AddEmailAddress", err)
|
||||
return
|
||||
} else {
|
||||
// Send confirmation e-mail
|
||||
if setting.Service.RegisterEmailConfirm {
|
||||
mailer.SendActivateEmail(ctx.Render, ctx.User, e)
|
||||
|
||||
cleanEmail := strings.Replace(form.Email, "\n", "", -1)
|
||||
e := &models.EmailAddress{
|
||||
Uid: ctx.User.Id,
|
||||
Email: cleanEmail,
|
||||
IsActivated: !setting.Service.RegisterEmailConfirm,
|
||||
}
|
||||
|
||||
if err := models.AddEmailAddress(e); err != nil {
|
||||
if err == models.ErrEmailAlreadyUsed {
|
||||
ctx.RenderWithErr(ctx.Tr("form.email_has_been_used"), SETTINGS_EMAILS, &form)
|
||||
return
|
||||
if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil {
|
||||
log.Error(4, "Set cache(MailResendLimit) fail: %v", err)
|
||||
}
|
||||
ctx.Handle(500, "email.AddEmailAddress", err)
|
||||
return
|
||||
ctx.Flash.Success(ctx.Tr("settings.add_email_success_confirmation_email_sent"))
|
||||
} else {
|
||||
|
||||
// Send confirmation e-mail
|
||||
if setting.Service.RegisterEmailConfirm {
|
||||
mailer.SendActivateEmail(ctx.Render, ctx.User, e)
|
||||
|
||||
if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil {
|
||||
log.Error(4, "Set cache(MailResendLimit) fail: %v", err)
|
||||
}
|
||||
ctx.Flash.Success(ctx.Tr("settings.add_email_success_confirmation_email_sent"))
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("settings.add_email_success"))
|
||||
}
|
||||
|
||||
log.Trace("Email address added: %s", e.Email)
|
||||
|
||||
ctx.Redirect(setting.AppSubUrl + "/user/settings/email")
|
||||
return
|
||||
ctx.Flash.Success(ctx.Tr("settings.add_email_success"))
|
||||
}
|
||||
|
||||
log.Trace("Email address added: %s", e.Email)
|
||||
ctx.Redirect(setting.AppSubUrl + "/user/settings/email")
|
||||
return
|
||||
}
|
||||
|
||||
ctx.HTML(200, SETTINGS_EMAILS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue