|
Is there any way to have two login pages (in grails) that each one
redirects to a specified default url? admin/login -> redirect to /admin/dashboard user/login -> redirect to /user/dashboard Thanks! Volnei Granado Munhoz --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Volnei Munhoz
|
|
Hi, 1. create AppAuthSuccessHandler class somewhere: [code] class AppAuthSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
String adminUrl String userUrl @Override protected String determineTargetUrl(HttpServletRequest request, HttpServletResponse response) {
if (SpringSecurityUtils.ifAllGranted('ROLE_ADMIN')) { return adminUrl } if (SpringSecurityUtils.ifAllGranted('ROLE_USER')) {
return userUrl } return super.determineTargetUrl(request, response); } } [/code] 2. then register your class in "resources.groovy" file: [code] authenticationSuccessHandler(AppAuthSuccessHandler) { def conf = SpringSecurityUtils.securityConfig
requestCache = ref('requestCache') defaultTargetUrl = conf.successHandler.defaultTargetUrl alwaysUseDefaultTargetUrl = conf.successHandler.alwaysUseDefault
targetUrlParameter = conf.successHandler.targetUrlParameter useReferer = conf.successHandler.useReferer redirectStrategy = ref('redirectStrategy') adminUrl = "/admin/dashboard"
userUrl = "/user/dashboard" } [/code] Regards, Mihai
On Wed, Jul 11, 2012 at 11:43 PM, Volnei <[hidden email]> wrote: Is there any way to have two login pages (in grails) that each one Mihai Cazacu Software Engineer E-mail: [hidden email] Mobile: +40 745 254 657 Skype: cazacugmihai
Twitter: cazacugmihai |
|
Hi Mihai, thanks for your reply!
But it's is not my goal... I need two different login pages each one with your layout and rules. But ssc only supports one auth.loginFormUrl. Regards Volnei Granado Munhoz 2012/7/12 Mihai Cazacu <[hidden email]>: > Hi, > > Try something like this: > > 1. create AppAuthSuccessHandler class somewhere: > > [code] > class AppAuthSuccessHandler extends > SavedRequestAwareAuthenticationSuccessHandler { > > String adminUrl > String userUrl > > @Override > protected String determineTargetUrl(HttpServletRequest request, > HttpServletResponse response) { > > if (SpringSecurityUtils.ifAllGranted('ROLE_ADMIN')) { > return adminUrl > } > > if (SpringSecurityUtils.ifAllGranted('ROLE_USER')) { > return userUrl > } > > return super.determineTargetUrl(request, response); > } > > } > [/code] > > 2. then register your class in "resources.groovy" file: > > [code] > authenticationSuccessHandler(AppAuthSuccessHandler) { > def conf = SpringSecurityUtils.securityConfig > > requestCache = ref('requestCache') > defaultTargetUrl = conf.successHandler.defaultTargetUrl > alwaysUseDefaultTargetUrl = conf.successHandler.alwaysUseDefault > targetUrlParameter = conf.successHandler.targetUrlParameter > useReferer = conf.successHandler.useReferer > redirectStrategy = ref('redirectStrategy') > adminUrl = "/admin/dashboard" > userUrl = "/user/dashboard" > } > [/code] > > Regards, > Mihai > > On Wed, Jul 11, 2012 at 11:43 PM, Volnei <[hidden email]> wrote: >> >> Is there any way to have two login pages (in grails) that each one >> redirects to a specified default url? >> >> admin/login -> redirect to /admin/dashboard >> user/login -> redirect to /user/dashboard >> >> Thanks! >> >> >> Volnei Granado Munhoz >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > > > > -- > Mihai Cazacu > Software Engineer > E-mail: [hidden email] > Mobile: +40 745 254 657 > Skype: cazacugmihai > Twitter: cazacugmihai > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Volnei Munhoz
|
|
Oh, I see now...
In this case, add in admin login page an extra parameter: <g:hiddenField name="asAdmin" value="${true}"/> then:
1. extend ExceptionMappingAuthenticationFailureHandler and deal with that param. public void onAuthenticationFailure(final HttpServletRequest request, final HttpServletResponse response,
final AuthenticationException exception) throws IOException, ServletException { if (reques.asAdmin == 'true') ...
} 2. extend GormUserDetailsService and make the same think: UserDetails loadUserByUsername(String emailOrPhone, boolean loadRoles) {
if (RequestContextHolder.requestAttributes?.params?.
asAdmin == 'true') ... } and don't forget to register this beans in resources.groovy. Regards, Mihai
On Thu, Jul 12, 2012 at 2:58 PM, Volnei <[hidden email]> wrote: Hi Mihai, thanks for your reply! Mihai Cazacu Software Engineer E-mail: [hidden email] Mobile: <a href="tel:%2B40%20745%20254%20657" value="+40745254657" target="_blank">+40 745 254 657 Skype: cazacugmihai Twitter: cazacugmihai |
|
Hi Mihai!!
Thanks a lot!!!!!!! =) []'s Volnei Granado Munhoz 2012/7/12 Mihai Cazacu <[hidden email]>: > Oh, I see now... > > In this case, add in admin login page an extra parameter: > > <g:hiddenField name="asAdmin" value="${true}"/> > > then: > > 1. extend ExceptionMappingAuthenticationFailureHandler and deal with that > param. > > public void onAuthenticationFailure(final HttpServletRequest request, final > HttpServletResponse response, > final AuthenticationException > exception) throws IOException, ServletException { > if (reques.asAdmin == 'true') ... > } > > > 2. extend GormUserDetailsService and make the same think: > > UserDetails loadUserByUsername(String emailOrPhone, boolean loadRoles) { > if (RequestContextHolder.requestAttributes?.params?. asAdmin == 'true') > ... > } > > and don't forget to register this beans in resources.groovy. > > Regards, > Mihai > > > On Thu, Jul 12, 2012 at 2:58 PM, Volnei <[hidden email]> wrote: >> >> Hi Mihai, thanks for your reply! >> >> But it's is not my goal... >> >> I need two different login pages each one with your layout and rules. >> But ssc only supports one auth.loginFormUrl. >> >> Regards >> Volnei Granado Munhoz >> >> >> 2012/7/12 Mihai Cazacu <[hidden email]>: >> > Hi, >> > >> > Try something like this: >> > >> > 1. create AppAuthSuccessHandler class somewhere: >> > >> > [code] >> > class AppAuthSuccessHandler extends >> > SavedRequestAwareAuthenticationSuccessHandler { >> > >> > String adminUrl >> > String userUrl >> > >> > @Override >> > protected String determineTargetUrl(HttpServletRequest request, >> > HttpServletResponse response) { >> > >> > if (SpringSecurityUtils.ifAllGranted('ROLE_ADMIN')) { >> > return adminUrl >> > } >> > >> > if (SpringSecurityUtils.ifAllGranted('ROLE_USER')) { >> > return userUrl >> > } >> > >> > return super.determineTargetUrl(request, response); >> > } >> > >> > } >> > [/code] >> > >> > 2. then register your class in "resources.groovy" file: >> > >> > [code] >> > authenticationSuccessHandler(AppAuthSuccessHandler) { >> > def conf = SpringSecurityUtils.securityConfig >> > >> > requestCache = ref('requestCache') >> > defaultTargetUrl = conf.successHandler.defaultTargetUrl >> > alwaysUseDefaultTargetUrl = conf.successHandler.alwaysUseDefault >> > targetUrlParameter = conf.successHandler.targetUrlParameter >> > useReferer = conf.successHandler.useReferer >> > redirectStrategy = ref('redirectStrategy') >> > adminUrl = "/admin/dashboard" >> > userUrl = "/user/dashboard" >> > } >> > [/code] >> > >> > Regards, >> > Mihai >> > >> > On Wed, Jul 11, 2012 at 11:43 PM, Volnei <[hidden email]> >> > wrote: >> >> >> >> Is there any way to have two login pages (in grails) that each one >> >> redirects to a specified default url? >> >> >> >> admin/login -> redirect to /admin/dashboard >> >> user/login -> redirect to /user/dashboard >> >> >> >> Thanks! >> >> >> >> >> >> Volnei Granado Munhoz >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe from this list, please visit: >> >> >> >> http://xircles.codehaus.org/manage_email >> >> >> >> >> > >> > >> > >> > -- >> > Mihai Cazacu >> > Software Engineer >> > E-mail: [hidden email] >> > Mobile: +40 745 254 657 >> > Skype: cazacugmihai >> > Twitter: cazacugmihai >> > >> > >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > > > > -- > Mihai Cazacu > Software Engineer > E-mail: [hidden email] > Mobile: +40 745 254 657 > Skype: cazacugmihai > Twitter: cazacugmihai > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Volnei Munhoz
|
| Powered by Nabble | Edit this page |
