fix(handler): missing notification values (#3321)
This ensures all template types share the same template values and display them correctly regardless if text/html/other. Fixes #3319.pull/3323/head
parent
39a97cdaa5
commit
a7106ad7e9
|
@ -36,9 +36,7 @@ func ResetPasswordPOST(ctx *middlewares.AutheliaCtx) {
|
|||
return
|
||||
}
|
||||
|
||||
err = ctx.Providers.UserProvider.UpdatePassword(username, requestBody.Password)
|
||||
|
||||
if err != nil {
|
||||
if err = ctx.Providers.UserProvider.UpdatePassword(username, requestBody.Password); err != nil {
|
||||
switch {
|
||||
case utils.IsStringInSliceContains(err.Error(), ldapPasswordComplexityCodes),
|
||||
utils.IsStringInSliceContains(err.Error(), ldapPasswordComplexityErrors):
|
||||
|
@ -54,9 +52,8 @@ func ResetPasswordPOST(ctx *middlewares.AutheliaCtx) {
|
|||
|
||||
// Reset the request.
|
||||
userSession.PasswordResetUsername = nil
|
||||
err = ctx.SaveSession(userSession)
|
||||
|
||||
if err != nil {
|
||||
if err = ctx.SaveSession(userSession); err != nil {
|
||||
ctx.Error(fmt.Errorf("unable to update password reset state: %s", err), messageOperationFailed)
|
||||
return
|
||||
}
|
||||
|
@ -84,14 +81,14 @@ func ResetPasswordPOST(ctx *middlewares.AutheliaCtx) {
|
|||
disableHTML = ctx.Configuration.Notifier.SMTP.DisableHTMLEmails
|
||||
}
|
||||
|
||||
if !disableHTML {
|
||||
htmlParams := map[string]interface{}{
|
||||
data := map[string]interface{}{
|
||||
"Title": "Password changed successfully",
|
||||
"DisplayName": userInfo.DisplayName,
|
||||
"RemoteIP": ctx.RemoteIP().String(),
|
||||
}
|
||||
|
||||
err = templates.EmailPasswordResetHTML.Execute(bufHTML, htmlParams)
|
||||
if !disableHTML {
|
||||
err = templates.EmailPasswordResetHTML.Execute(bufHTML, data)
|
||||
|
||||
if err != nil {
|
||||
ctx.Logger.Error(err)
|
||||
|
@ -102,13 +99,8 @@ func ResetPasswordPOST(ctx *middlewares.AutheliaCtx) {
|
|||
}
|
||||
|
||||
bufText := new(bytes.Buffer)
|
||||
textParams := map[string]interface{}{
|
||||
"DisplayName": userInfo.DisplayName,
|
||||
}
|
||||
|
||||
err = templates.EmailPasswordResetPlainText.Execute(bufText, textParams)
|
||||
|
||||
if err != nil {
|
||||
if err = templates.EmailPasswordResetPlainText.Execute(bufText, data); err != nil {
|
||||
ctx.Logger.Error(err)
|
||||
ctx.ReplyOK()
|
||||
|
||||
|
@ -118,9 +110,7 @@ func ResetPasswordPOST(ctx *middlewares.AutheliaCtx) {
|
|||
ctx.Logger.Debugf("Sending an email to user %s (%s) to inform that the password has changed.",
|
||||
username, userInfo.Emails[0])
|
||||
|
||||
err = ctx.Providers.Notifier.Send(userInfo.Emails[0], "Password changed successfully", bufText.String(), bufHTML.String())
|
||||
|
||||
if err != nil {
|
||||
if err = ctx.Providers.Notifier.Send(userInfo.Emails[0], "Password changed successfully", bufText.String(), bufHTML.String()); err != nil {
|
||||
ctx.Logger.Error(err)
|
||||
ctx.ReplyOK()
|
||||
|
||||
|
|
|
@ -49,15 +49,14 @@ func IdentityVerificationStart(args IdentityVerificationStartArgs, delayFunc Tim
|
|||
claims := verification.ToIdentityVerificationClaim()
|
||||
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
ss, err := token.SignedString([]byte(ctx.Configuration.JWTSecret))
|
||||
|
||||
ss, err := token.SignedString([]byte(ctx.Configuration.JWTSecret))
|
||||
if err != nil {
|
||||
ctx.Error(err, messageOperationFailed)
|
||||
return
|
||||
}
|
||||
|
||||
err = ctx.Providers.StorageProvider.SaveIdentityVerification(ctx, verification)
|
||||
if err != nil {
|
||||
if err = ctx.Providers.StorageProvider.SaveIdentityVerification(ctx, verification); err != nil {
|
||||
ctx.Error(err, messageOperationFailed)
|
||||
return
|
||||
}
|
||||
|
@ -77,8 +76,7 @@ func IdentityVerificationStart(args IdentityVerificationStartArgs, delayFunc Tim
|
|||
disableHTML = ctx.Configuration.Notifier.SMTP.DisableHTMLEmails
|
||||
}
|
||||
|
||||
if !disableHTML {
|
||||
htmlParams := map[string]interface{}{
|
||||
data := map[string]interface{}{
|
||||
"Title": args.MailTitle,
|
||||
"LinkURL": link,
|
||||
"LinkText": args.MailButtonContent,
|
||||
|
@ -86,23 +84,16 @@ func IdentityVerificationStart(args IdentityVerificationStartArgs, delayFunc Tim
|
|||
"RemoteIP": ctx.RemoteIP().String(),
|
||||
}
|
||||
|
||||
err = templates.EmailIdentityVerificationHTML.Execute(bufHTML, htmlParams)
|
||||
|
||||
if err != nil {
|
||||
if !disableHTML {
|
||||
if err = templates.EmailIdentityVerificationHTML.Execute(bufHTML, data); err != nil {
|
||||
ctx.Error(err, messageOperationFailed)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
bufText := new(bytes.Buffer)
|
||||
textParams := map[string]interface{}{
|
||||
"LinkURL": link,
|
||||
"DisplayName": identity.DisplayName,
|
||||
}
|
||||
|
||||
err = templates.EmailIdentityVerificationPlainText.Execute(bufText, textParams)
|
||||
|
||||
if err != nil {
|
||||
if err = templates.EmailIdentityVerificationPlainText.Execute(bufText, data); err != nil {
|
||||
ctx.Error(err, messageOperationFailed)
|
||||
return
|
||||
}
|
||||
|
@ -110,9 +101,7 @@ func IdentityVerificationStart(args IdentityVerificationStartArgs, delayFunc Tim
|
|||
ctx.Logger.Debugf("Sending an email to user %s (%s) to confirm identity for registering a device.",
|
||||
identity.Username, identity.Email)
|
||||
|
||||
err = ctx.Providers.Notifier.Send(identity.Email, args.MailTitle, bufText.String(), bufHTML.String())
|
||||
|
||||
if err != nil {
|
||||
if err = ctx.Providers.Notifier.Send(identity.Email, args.MailTitle, bufText.String(), bufHTML.String()); err != nil {
|
||||
ctx.Error(err, messageOperationFailed)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue