Closed jaybytez closed 10 years ago
I was able to get around this with some kludge. There doesn't appear to be anyway to change where the doLogin routes too (partially because I am new to Play and cannot find a way to evaluate a Result's path). So I did the following code where I try to cast the response within the doLogin and determine if the path is "/", so that I can redirect them to their profile (as an example). Unless the Result is to another location (like an error happening), I allow that path to continue. Please share if there is a better way:
Results.Redirect redirect = (Results.Redirect)UsernamePasswordAuthProvider.handleLogin(ctx()); if(StringUtils.contains(redirect.getWrappedSimpleResult().toString(), "/)")) { return Application.profile(); } return redirect;
You can rewirte Global.afterAuth() as explained in https://github.com/joscha/play-authenticate/blob/master/samples/java/Getting%20Started.md
Worked like a charm...thanks a ton!
Is there a way to dynamically change this to where the user was before he logged in/out?
@amosjyng not out of the box, but you could save that value somewhere and read it in afterAuth
@joscha hm, would you recommend putting the session and page into the cache?
@amosjyng the cache is always a bad place once your application is spread throughout multiple nodes and/or gets rebooted, etc. The page could be put in the session I guess as its small enough to do so. As long as the cookie exists, there is a location you can jump back to and when/if the user deletes his/her cookies I think it is fair enough to also not return to that page.
Is there any easy way to change the redirect after login to something other than "/"?
Jay