mesutpiskin / keycloak-2fa-email-authenticator

🔒 Keycloak Authentication Provider implementation to get a two factor authentication with a OTP/code/token send via Email (through SMTP)
https://medium.com/@mesutpiskin/two-factor-authentication-via-email-in-keycloak-custom-auth-spi-935bbb3952a8
Apache License 2.0
140 stars 83 forks source link

secret code is not coming in email. only emailCodeBody is showing in my email #14

Closed abhi8054 closed 1 year ago

abhi8054 commented 1 year ago

image

html : <html><body> ${kcSanitize(msg("emailCodeBody",code))?no_esc} </body> </html>

text : <#ftl output_format="plainText"> ${msg("emailCodeBody", code)}

mesutpiskin commented 1 year ago

GPT Answer:

"If you are encountering an issue where the secret code is not appearing in the email and only the emailCodeBody content is displayed, you can follow these steps to troubleshoot the problem:

Check the Email Template: Verify the template used for the emails sent by Keycloak. Ensure that the template is properly configured and that the emailCodeBody value is correctly included. Make sure that the template is correctly formatted for both HTML and plain text versions.

Use the Correct Variable in the Template: In the email template, ensure that you are using the correct variable to include the secret code. You may need to insert the desired secret code into your template using a variable like ${code} or $!{code}.

Verify the kcSanitize Function: If you are using the kcSanitize function in the email template, check that the function is making the necessary modifications. This function is used to safely process the email content. Ensure that it is properly configured and correctly processing the emailCodeBody content.

Check Keycloak Configuration: Review your Keycloak settings and ensure that the email sending configuration is correct. Verify that you have provided the correct SMTP (Simple Mail Transfer Protocol) server and port number. Also, ensure that you have provided the necessary authentication credentials for email sending."