Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7559483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:39:01+00:00 2026-05-30T12:39:01+00:00

My grails web app has two parts: one for desktop / laptop browsers, one

  • 0

My grails web app has two parts: one for desktop / laptop browsers, one for mobile devices which uses jquery-mobile. The mobile part lives in a subtree /mobile/*. Using spring security I’d like to have different controllers/views for login, logout, etc. I haven’t found any useful hints researching this topic on the web.

The only option I can currently think of is to extract the mobile app into a grails project of its own which will then force me to extract common logic into a grails plugin which will then force me to a completely different dev and deployment set up and so on… I’d much rather keep mobile and non-mobile part in the same app but cannot figure out how.

Any suggestions appreciated…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:39:02+00:00Added an answer on May 30, 2026 at 12:39 pm

    Try this one again…

    I have been working on something similar lately as well. And had the same ‘wants’ as you. Here is what I ended up with.

    To point to different login screens I overwrote the AuthenticationEntryPoint step of the security filter chain (spring security). I used the same logic that the spring-mobile plugin uses. (In fact, you will have to have spring-mobile plugin installed for this to work) The deviceResolver is wired up by that plugin.

    package com.myapp.security
    
    import org.codehaus.groovy.grails.plugins.springsecurity.AjaxAwareAuthenticationEntryPoint
    import javax.servlet.http.HttpServletRequestimport javax.servlet.http.HttpServletResponse
    import org.springframework.security.core.AuthenticationException
    
    class MyAppAuthenticationEntryPoint extends AjaxAwareAuthenticationEntryPoint {
        def mobileLoginFormUrl
        def deviceResolver
    
        @Override
        protected String determineUrlToUseForThisRequest(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) {
            if (deviceResolver.resolveDevice(request).isMobile())
            {
                 return mobileLoginFormUrl
            }
            return super.determineUrlToUseForThisRequest(request, response, e)
        }
    }
    

    Wired like so in resources.groovy

    authenticationEntryPoint(com.myapp.security.MyAppAuthenticationEntryPoint) {
        loginFormUrl = conf.auth.loginFormUrl
        forceHttps = conf.auth.forceHttps
        ajaxLoginFormUrl = conf.auth.ajaxLoginFormUrl
        useForward = conf.auth.useForward
        portMapper = ref('portMapper')
        portResolver = ref('portResolver')
        deviceResolver = ref('deviceResolver')
        mobileLoginFormUrl = conf.auth.mobileLoginFormUrl
    }
    

    Config lines in Config.groovy

    grails.plugins.springsecurity.auth.loginFormUrl = '/register'
    grails.plugins.springsecurity.auth.mobileLoginFormUrl = '/mobile/login'
    

    I have also written my AuthenticationSuccessHandler step to force mobile users to the mobile landing page after login.

    package com.myapp.security
    
    import javax.servlet.http.HttpServletRequest
    import javax.servlet.http.HttpServletResponse
    import org.codehaus.groovy.grails.plugins.springsecurity.AjaxAwareAuthenticationSuccessHandler
    import org.springframework.security.web.savedrequest.RequestCache
    
    class MyAppAuthenticationSuccessHandler extends AjaxAwareAuthenticationSuccessHandler {
        def mobileTargetUrl
        def deviceResolver
        RequestCache requestCache
    
        @Override
        protected String determineTargetUrl(HttpServletRequest request, HttpServletResponse response) {
             if (isMobile(request))
             {
                 return mobileTargetUrl
             }
             return super.determineTargetUrl(request, response)
        }
    
        @Override
        void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, org.springframework.security.core.Authentication authentication) {        
            if (isMobile(request))
            {
                // we always want to go to the mobile landing page here.
                requestCache.removeRequest(request, response);
            }
            super.onAuthenticationSuccess(request, response, authentication)
        }
    
        private boolean isMobile(request) {
            deviceResolver.resolveDevice(request).isMobile()
        }
    
        @Override
        void setRequestCache(RequestCache requestCache) {
            super.setRequestCache(requestCache)
            this.requestCache = requestCache
        }
    
    }
    

    This doesn’t stop the user from browsing to a non-mobile page, but it does force them to the /mobile/index after login. Form there all my links on my mobile pages refer to other mobile pages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two grails servers: Server - has read/write access to the database Web
Grails vs Rails. Which has better support? And which one is a better choice
I'm writing a web app using grails and spring-security 3.0.3 which requires me to
I have two Jetty AppServers running a Grails Web App behind Apache 2.2 reverse
Inside a grails application, I need to upload a file under web-app/js, add a
I am having Grails GORM based application.One web service and one website both are
I am working on a web application (using Grails) which will generate a gift
I am creating a Grails application that has read-only access to a web service
I'm working on a Grails web app that would be similar in access patterns
Hey all- I'm working on some web flows for a Grails app we're building.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.