Grails Spring Security:登录成功/失败后重定向 [英] Grails Spring Security: redirect after login success/failure
问题描述
我在Grails应用程序中使用Spring Security插件的1.2版本。我希望以下列方式处理登录尝试: 我看了一下活动部分插件的手册,这似乎涵盖了这一点。然而,在这些事件处理程序中,似乎没有任何方法可以重定向用户。 当您点击一个安全链接并且没有登录时,一个 先前输入的登录名称将重新显示,请在 I'm using version 1.2 of the Spring Security plugin in a Grails application. I want login attempts to be handled in the following way: I've had a look at the Events section of the plugin's manual, which seems to cover this ground. However there doesn't seem to be any way to redirect a user within these event handlers. You're basically describing how it currently works except for re-displaying login details, which is straightforward. When you click a secured link and aren't logged in, a To get the previously entered login name to re-display, use the
这篇关于Grails Spring Security:登录成功/失败后重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
成功
$ b 失败
SavedRequest
存储在会话中以跟踪您想要去的地方。成功登录后,将检查此对象,并从中构建重定向。如果直接进入登录页面,则没有保存的信息,因此它会重定向到默认位置。默认情况下,它是应用程序的根目录('/'
),但它是可配置的,例如
grails.plugins.springsecurity.successHandler.defaultTargetUrl ='/ home'
auth.gsp
中使用 SPRING_SECURITY_LAST_USERNAME
会话密钥:
< input type ='text'class ='text_'name ='j_username'id ='username'
value = $ {session ['SPRING_SECURITY_LAST_USERNAME']}/>
Success
Failure
SavedRequest
is stored in the session to keep track of where you were trying to go. After a successful login, this object is inspected and the redirect is built from it. If you go directly to the login page there's no saved info, so it redirects to a default location. By default it's the root of the app ('/'
) but it's configurable, e.g.grails.plugins.springsecurity.successHandler.defaultTargetUrl = '/home'
SPRING_SECURITY_LAST_USERNAME
session key in auth.gsp
:<input type='text' class='text_' name='j_username' id='username'
value="${session['SPRING_SECURITY_LAST_USERNAME']}" />