WIP: Added a controller, to manage permissions
authorKai Moritz <kai@juplo.de>
Thu, 28 Jan 2016 20:05:38 +0000 (21:05 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 3 Jul 2018 15:18:12 +0000 (17:18 +0200)
src/main/java/de/juplo/yourshouter/PermissionsController.java

index e3a9820..1251bda 100644 (file)
@@ -1,7 +1,11 @@
 package de.juplo.yourshouter;
 
+import java.io.PrintWriter;
 import java.util.List;
+import java.util.Map;
 import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import org.springframework.social.connect.ConnectionFactoryLocator;
 import org.springframework.social.connect.ConnectionRepository;
 import org.springframework.social.connect.web.ConnectController;
@@ -13,6 +17,7 @@ import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.context.request.NativeWebRequest;
+import org.springframework.web.servlet.View;
 import org.springframework.web.servlet.view.RedirectView;
 
 
@@ -49,9 +54,35 @@ public class PermissionsController extends ConnectController
   }
 
   @RequestMapping(method=RequestMethod.POST)
-  public RedirectView connect(NativeWebRequest request)
+  public View connect(NativeWebRequest request)
   {
-    return super.connect("facebook", request);
+    final RedirectView redirect = super.connect("facebook", request);
+    return new View()
+    {
+      @Override
+      public String getContentType()
+      {
+        return "text/html";
+      }
+
+      @Override
+      public void render(
+          Map<String, ?> model,
+          HttpServletRequest request,
+          HttpServletResponse response
+          )
+          throws
+            Exception
+      {
+        PrintWriter writer = response.getWriter();
+        writer.write("<script>");
+        writer.write("top.location.href='");
+        writer.write(redirect.getUrl());
+        writer.write("';");
+        writer.write("</script>");
+        response.flushBuffer();
+      }
+       };
   }
 
   @Override