如何在WSO2 IS 5.11.0自定义登录页显示锁定用户的自定义错误信息
解决WSO2 IS 5.11.0账户锁定时在自定义登录页显示错误的问题
1. 关闭认证重试页重定向
默认情况下,账户锁定等认证失败场景会跳转到/authenticationendpoint/retry.do,需修改认证端点配置关闭该行为:
- 进入WSO2 IS安装目录下的
repository/deployment/server/webapps/authenticationendpoint/WEB-INF/classes/conf - 编辑
authenticationendpoint.properties文件,将AuthenticationRetryPageEnable参数值改为false - 重启WSO2 IS服务
2. 自定义账户锁定错误文本
修改认证端点的消息资源文件,替换默认错误内容:
- 进入
repository/deployment/server/webapps/authenticationendpoint/WEB-INF/classes/resources - 编辑
messages.properties(中文环境编辑messages_zh.properties),找到对应键值对并修改:
将值替换为你需要的自定义错误信息account.locked=您的账户已锁定,请联系管理员解锁后再尝试登录。
3. 改造自定义登录页接收错误参数
认证失败(含账户锁定)时,WSO2 IS会通过errorCode和errorMessage参数将错误信息传递回登录页,需在自定义登录页添加渲染逻辑:
- 检测URL中是否存在
errorMessage参数 - 若存在,在页面指定位置展示该参数内容
示例(HTML+JS):<div id="error-box" style="display:none; color:#dc3545; padding:10px; border:1px solid #f5c6cb; border-radius:4px;"></div> <script> const params = new URLSearchParams(window.location.search); const errMsg = params.get('errorMessage'); if (errMsg) { document.getElementById('error-box').textContent = errMsg; document.getElementById('error-box').style.display = 'block'; } </script>
4. 验证效果
- 锁定一个测试用户账户
- 使用该账户尝试登录,确认页面停留在自定义登录页并显示你设置的错误信息
内容的提问来源于stack exchange,提问作者Victor Da Silva
相关产品推荐
相关产品推荐

