Grails Spring Security Core 插件 - 将 flash 消息添加到登录页面
我正在使用 Grails Spring Security Core Plugin 使用以下注释来保护特定操作。
@Secured(['IS_AUTHENTICATED_REMEMBERED'])
如果用户未登录,这会导致操作重定向到我的登录页面。登录后,他们将被重定向到原始操作。
在这种情况下,如何将 Flash 消息添加到登录页面,即
flash.message = "You must be logged in to submit a news story"
为了澄清,我只想在用户尝试访问此特定操作后重定向到登录页面时显示该消息。其他操作不会触发该消息。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经解决了这个问题如下。
在操作的开头添加以下代码(news 和 Submit 分别是相关的控制器和操作)。
将以下内容添加到登录表单。
I have solved this as follows.
Add the following code at the beginning of the action (news and submit being the relevant controller and action respectively).
Add the following to the login form.
例如,将其添加到您的登录视图中:
请参阅 安全标签库文档。
Add, for example, this to your login view:
See the security taglib's documentation.