← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4923: made login from mobile, redirect to the mobile edition

 

------------------------------------------------------------
revno: 4923
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-10-13 11:26:39 +0200
message:
  made login from mobile, redirect to the mobile edition
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java	2011-09-02 08:18:24 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java	2011-10-13 09:26:39 +0000
@@ -34,6 +34,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.springframework.mobile.device.Device;
+import org.springframework.mobile.device.DeviceResolver;
 import org.springframework.security.web.DefaultRedirectStrategy;
 
 /**
@@ -58,6 +60,13 @@
         this.redirectMap = redirectMap;
     }
 
+    private DeviceResolver deviceResolver;
+
+    public void setDeviceResolver( DeviceResolver deviceResolver )
+    {
+        this.deviceResolver = deviceResolver;
+    }
+
     // -------------------------------------------------------------------------
     // DefaultRedirectStrategy implementation
     // -------------------------------------------------------------------------
@@ -66,6 +75,8 @@
     public void sendRedirect( HttpServletRequest request, HttpServletResponse response, String url )
         throws IOException
     {
+        Device device = deviceResolver.resolveDevice( request );
+
         for ( String key : redirectMap.keySet() )
         {
             if ( url.indexOf( key ) != -1 )
@@ -74,6 +85,12 @@
             }
         }
 
+        // TODO fix this
+        if ( device.isMobile() )
+        {
+            url = "../mobile/index.action";
+        }
+
         super.sendRedirect( request, response, url );
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml	2011-09-22 07:18:09 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml	2011-10-13 09:26:39 +0000
@@ -19,6 +19,7 @@
         </entry>
       </map>
     </property>
+    <property name="deviceResolver" ref="org.springframework.mobile.device.DeviceResolver" />
   </bean>
 
   <bean id="defaultAuthenticationSuccessHandler" class="org.hisp.dhis.security.DefaultAuthenticationSuccessHandler">
@@ -32,7 +33,7 @@
     <sec:http-basic />
     <sec:logout logout-url="/dhis-web-commons-security/logout.action" />
 
-    <sec:intercept-url pattern="/dhis-web-commons/security/**" access="permitAll"/>
+    <sec:intercept-url pattern="/dhis-web-commons/security/**" access="permitAll" />
     <sec:intercept-url pattern="/dhis-web-commons/javascripts/**" filters="none" />
     <sec:intercept-url pattern="/dhis-web-commons/css/**" filters="none" />
     <sec:intercept-url pattern="/favicon.ico" filters="none" />