mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
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.
This commit is contained in:
parent
39a97cdaa5
commit
a7106ad7e9
|
@ -36,9 +36,7 @@ func ResetPasswordPOST(ctx *middlewares.AutheliaCtx) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ctx.Providers.UserProvider.UpdatePassword(username, requestBody.Password)
|
if err = ctx.Providers.UserProvider.UpdatePassword(username, requestBody.Password); err != nil {
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
switch {
|
switch {
|
||||||
case utils.IsStringInSliceContains(err.Error(), ldapPasswordComplexityCodes),
|
case utils.IsStringInSliceContains(err.Error(), ldapPasswordComplexityCodes),
|
||||||
utils.IsStringInSliceContains(err.Error(), ldapPasswordComplexityErrors):
|
utils.IsStringInSliceContains(err.Error(), ldapPasswordComplexityErrors):
|
||||||
|
@ -54,9 +52,8 @@ func ResetPasswordPOST(ctx *middlewares.AutheliaCtx) {
|
||||||
|
|
||||||
// Reset the request.
|
// Reset the request.
|
||||||
userSession.PasswordResetUsername = nil
|
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)
|
ctx.Error(fmt.Errorf("unable to update password reset state: %s", err), messageOperationFailed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -84,14 +81,14 @@ func ResetPasswordPOST(ctx *middlewares.AutheliaCtx) {
|
||||||
disableHTML = ctx.Configuration.Notifier.SMTP.DisableHTMLEmails
|
disableHTML = ctx.Configuration.Notifier.SMTP.DisableHTMLEmails
|
||||||
}
|
}
|
||||||
|
|
||||||
if !disableHTML {
|
data := map[string]interface{}{
|
||||||
htmlParams := map[string]interface{}{
|
"Title": "Password changed successfully",
|
||||||
"Title": "Password changed successfully",
|
"DisplayName": userInfo.DisplayName,
|
||||||
"DisplayName": userInfo.DisplayName,
|
"RemoteIP": ctx.RemoteIP().String(),
|
||||||
"RemoteIP": ctx.RemoteIP().String(),
|
}
|
||||||
}
|
|
||||||
|
|
||||||
err = templates.EmailPasswordResetHTML.Execute(bufHTML, htmlParams)
|
if !disableHTML {
|
||||||
|
err = templates.EmailPasswordResetHTML.Execute(bufHTML, data)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Logger.Error(err)
|
ctx.Logger.Error(err)
|
||||||
|
@ -102,13 +99,8 @@ func ResetPasswordPOST(ctx *middlewares.AutheliaCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bufText := new(bytes.Buffer)
|
bufText := new(bytes.Buffer)
|
||||||
textParams := map[string]interface{}{
|
|
||||||
"DisplayName": userInfo.DisplayName,
|
|
||||||
}
|
|
||||||
|
|
||||||
err = templates.EmailPasswordResetPlainText.Execute(bufText, textParams)
|
if err = templates.EmailPasswordResetPlainText.Execute(bufText, data); err != nil {
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
ctx.Logger.Error(err)
|
ctx.Logger.Error(err)
|
||||||
ctx.ReplyOK()
|
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.",
|
ctx.Logger.Debugf("Sending an email to user %s (%s) to inform that the password has changed.",
|
||||||
username, userInfo.Emails[0])
|
username, userInfo.Emails[0])
|
||||||
|
|
||||||
err = ctx.Providers.Notifier.Send(userInfo.Emails[0], "Password changed successfully", bufText.String(), bufHTML.String())
|
if err = ctx.Providers.Notifier.Send(userInfo.Emails[0], "Password changed successfully", bufText.String(), bufHTML.String()); err != nil {
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
ctx.Logger.Error(err)
|
ctx.Logger.Error(err)
|
||||||
ctx.ReplyOK()
|
ctx.ReplyOK()
|
||||||
|
|
||||||
|
|
|
@ -49,15 +49,14 @@ func IdentityVerificationStart(args IdentityVerificationStartArgs, delayFunc Tim
|
||||||
claims := verification.ToIdentityVerificationClaim()
|
claims := verification.ToIdentityVerificationClaim()
|
||||||
|
|
||||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
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 {
|
if err != nil {
|
||||||
ctx.Error(err, messageOperationFailed)
|
ctx.Error(err, messageOperationFailed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ctx.Providers.StorageProvider.SaveIdentityVerification(ctx, verification)
|
if err = ctx.Providers.StorageProvider.SaveIdentityVerification(ctx, verification); err != nil {
|
||||||
if err != nil {
|
|
||||||
ctx.Error(err, messageOperationFailed)
|
ctx.Error(err, messageOperationFailed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -77,32 +76,24 @@ func IdentityVerificationStart(args IdentityVerificationStartArgs, delayFunc Tim
|
||||||
disableHTML = ctx.Configuration.Notifier.SMTP.DisableHTMLEmails
|
disableHTML = ctx.Configuration.Notifier.SMTP.DisableHTMLEmails
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data := map[string]interface{}{
|
||||||
|
"Title": args.MailTitle,
|
||||||
|
"LinkURL": link,
|
||||||
|
"LinkText": args.MailButtonContent,
|
||||||
|
"DisplayName": identity.DisplayName,
|
||||||
|
"RemoteIP": ctx.RemoteIP().String(),
|
||||||
|
}
|
||||||
|
|
||||||
if !disableHTML {
|
if !disableHTML {
|
||||||
htmlParams := map[string]interface{}{
|
if err = templates.EmailIdentityVerificationHTML.Execute(bufHTML, data); err != nil {
|
||||||
"Title": args.MailTitle,
|
|
||||||
"LinkURL": link,
|
|
||||||
"LinkText": args.MailButtonContent,
|
|
||||||
"DisplayName": identity.DisplayName,
|
|
||||||
"RemoteIP": ctx.RemoteIP().String(),
|
|
||||||
}
|
|
||||||
|
|
||||||
err = templates.EmailIdentityVerificationHTML.Execute(bufHTML, htmlParams)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
ctx.Error(err, messageOperationFailed)
|
ctx.Error(err, messageOperationFailed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bufText := new(bytes.Buffer)
|
bufText := new(bytes.Buffer)
|
||||||
textParams := map[string]interface{}{
|
|
||||||
"LinkURL": link,
|
|
||||||
"DisplayName": identity.DisplayName,
|
|
||||||
}
|
|
||||||
|
|
||||||
err = templates.EmailIdentityVerificationPlainText.Execute(bufText, textParams)
|
if err = templates.EmailIdentityVerificationPlainText.Execute(bufText, data); err != nil {
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
ctx.Error(err, messageOperationFailed)
|
ctx.Error(err, messageOperationFailed)
|
||||||
return
|
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.",
|
ctx.Logger.Debugf("Sending an email to user %s (%s) to confirm identity for registering a device.",
|
||||||
identity.Username, identity.Email)
|
identity.Username, identity.Email)
|
||||||
|
|
||||||
err = ctx.Providers.Notifier.Send(identity.Email, args.MailTitle, bufText.String(), bufHTML.String())
|
if err = ctx.Providers.Notifier.Send(identity.Email, args.MailTitle, bufText.String(), bufHTML.String()); err != nil {
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
ctx.Error(err, messageOperationFailed)
|
ctx.Error(err, messageOperationFailed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user