When a user is created through the Keycloak admin console, is there a way to notify a user via email that a profile has been created and the user can finish registration following by a link? Currently, the user can get an email about profile being created only if after creation a password had been set for the user. And only after an initial login attempt. But for this login attempt, the user should know the password that was set.
小智 25
我通过为发送的电子邮件和登录页面自定义 keycloak 主题模板来完成同样的事情。这是关于如何自定义主题的Keycloak 文档。
这是我如何做到的具体细节:
首先,我将 executeActions.ftl 电子邮件模板自定义为漂亮并说“欢迎使用我们的应用程序,单击下面的链接以完成您的帐户设置”。我继续使用默认基本模板中的链接和链接到期说明。您可以在https://github.com/keycloak/keycloak/blob/master/themes/src/main/resources/theme/base/email/html/executeActions.ftl查看默认的基本模板
其次,我们决定了新用户“需要”哪些标准的keycloak操作。我们决定要完成注册,用户需要执行以下操作:
第三,我们设置 Keycloak 领域以要求所有用户完成 3 个步骤。
在 Keycloak 管理控制台中,我们将这些设置为“必需”操作(在配置-->身份验证-->必需操作下),将“条款和条件”、“更新配置文件”和“更新密码”操作标记为“已启用” ”和“默认操作”。我们还按照我们希望它们在“帐户设置”过程中出现的确切顺序放置这些操作,以便用户逐屏浏览。对于其他操作,我们取消选中默认操作。

第四,我自定义了以下呈现帐户设置页面的 keycloak 登录模板。嵌入在 executeActions 电子邮件中的 keycloak 生成的链接(来自第 1 步)会将用户带到这些“帐户设置”网页:
<!-- info.ftl -->
<#import "template.ftl" as layout>
<@layout.registrationLayout displayMessage=false; section>
<#if section = "header">
<#if messageHeader??>
${messageHeader}
<#else>
<#if message.summary == msg('confirmExecutionOfActions')>
${kcSanitize(msg('welcomeToOurApplication'))?no_esc}
<#elseif message.summary == msg('accountUpdatedMessage')>
${kcSanitize(msg('accountSuccessfullySetup'))?no_esc}
<#else>
${message.summary}
</#if>
</#if>
<#elseif section = "form">
<div id="kc-info-message">
<div class="kc-info-wrapper">
<#if message.summary == msg('confirmExecutionOfActions')>
${kcSanitize(msg('startSettingUpAccount'))?no_esc}
<#elseif message.summary == msg('accountUpdatedMessage')>
${kcSanitize(msg('accountIsReadyPleaseLogin'))?no_esc}
<#else>
${message.summary}
</#if>
</div>
<#if pageRedirectUri??>
... <!-- Omitted the rest because it's the same as the base template -->
Run Code Online (Sandbox Code Playgroud)
我还自定义了以下模板,它们对应于帐户设置过程中的步骤。
第五,当管理员创建一个新用户时,他/她会触发发送给该用户的欢迎电子邮件: - 在 Keycloak 管理控制台中,一旦您“添加”一个新用户,请转到该用户的“凭据”选项卡,然后在凭据重置在“重置操作”下选择所需的帐户设置操作,然后单击“发送电子邮件”按钮。
无论如何,我希望这会有所帮助。我记得我花了一点时间才弄明白,因为它不是 keycloak 中的标准流程。
| 归档时间: |
|
| 查看次数: |
5915 次 |
| 最近记录: |