Redirect page based on userlogin type

前端 未结 2 981
长发绾君心
长发绾君心 2021-01-26 05:05

Upon successful user login i want the page to redirect to /person/personCreate and it did work after adding the following code to Config.groovy.

<
2条回答
  •  抹茶落季
    2021-01-26 05:52

    In the spring security plugin, you'll find a LoginController.groovy.template and an auth.gsp.template.

    You should copy those into your project and then modify the def auth() method to look something like this:

    /**
     * Show the login page.
     */
    def auth = {
        def config = SpringSecurityUtils.securityConfig
    
        if (springSecurityService.isLoggedIn()) {
            def currentUser = springSecurityService.currentUser
            if (currentUser.userType.human)) {
                redirect controller: 'human'
            }
            else if (currentUser.userType.superHuman) {
                redirect controller: 'superHuman'
            }
            else {
                redirect uri: config.successHandler.defaultTargetUrl
            }
    
            return
        }
    
        String view = 'auth'
        String postUrl = "${request.contextPath}${config.apf.filterProcessesUrl}"
        render view: view, model: [postUrl: postUrl,
                                   rememberMeParameter: config.rememberMe.parameter]
    }
    

提交回复
热议问题