i experimenting grails 3 , new concept of interceptors. given following interceptor/controller:
class authinterceptor { // ...other stuff in here boolean before() { if(fizzbuzz.isfoo()) { redirect(controller: auth, action: signin) true } else { true } } } class authcontroller { authservice authservice def signin() { string username = params[username] string password = params[password] user = authservice.authenticate(username, password) if(user) { simplesecurityutils.setcurrentuser(user) redirect(url: ??? intended_destination ???) } else { // auth failed. redirect(action: failed) } } }
authservice
grails service. there 1 instance ofauthservice
per instance ofauthcontroller
. ,authcontroller
haveprototype
scope such never storing state, , controller created each request. have change in both (authservice
/authcontroller
) meet these scope requirements?- assuming
authcontroller#signin
executed dueredirect(controller:auth, action: signin)
inside interceptor, how redirect (yet again) user intended destination (that is, url wanted go prior interceptor intercepting request) inside controller action above?
first, if redirect url, must return false cancel rendering process, e.g.
redirect(controller: auth, action: signin) false
second, if want previews intended url, must save it, may be, session, , redirect saved url when finish signin process.