Added a controller, to manage permissions
authorKai Moritz <kai@juplo.de>
Mon, 1 Feb 2016 17:25:48 +0000 (18:25 +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 [new file with mode: 0644]
src/main/webapp/thymeleaf/home.html
src/main/webapp/thymeleaf/permissions.html [new file with mode: 0644]

diff --git a/src/main/java/de/juplo/yourshouter/PermissionsController.java b/src/main/java/de/juplo/yourshouter/PermissionsController.java
new file mode 100644 (file)
index 0000000..1ce9c1d
--- /dev/null
@@ -0,0 +1,39 @@
+package de.juplo.yourshouter;
+
+import java.util.List;
+import javax.inject.Inject;
+
+import org.springframework.social.facebook.api.Facebook;
+import org.springframework.social.facebook.api.Permission;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+
+/**
+ * Controller, that handles requests to the root of the application.
+ *
+ * @author Kai Moritz
+ */
+@Controller
+public class PermissionsController
+{
+  private final Facebook facebook;
+
+
+  @Inject
+  public PermissionsController(Facebook facebook)
+  {
+    this.facebook = facebook;
+  }
+
+
+  @RequestMapping(value = "/permissions.html", method = RequestMethod.GET)
+  public String list(Model model)
+  {
+    List<Permission> permissions = facebook.userOperations().getUserPermissions();
+    model.addAttribute("permissions", permissions);
+    return "permissions";
+  }
+}
index f7649e5..b9d94f9 100644 (file)
@@ -9,6 +9,7 @@
       <li><a href="connect/facebookConnected.html" th:href="@{/connect/facebook.html}">Show connection-status</a></li>
       <li><a href="profile.html" th:href="@{/profile.html}">Show public profile-data</a></li>
       <li><a href="#" th:href="@{/h2-console}">Connect to the H2-console</a></li>
+      <li><a href="permissions.html" th:href="@{/permissions.html}">Manage permissions</a></li>
     </ul>
   </body>
 </html>
diff --git a/src/main/webapp/thymeleaf/permissions.html b/src/main/webapp/thymeleaf/permissions.html
new file mode 100644 (file)
index 0000000..2afd746
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
+  <head>
+    <title>Manage Permissions</title>
+  </head>
+  <body>
+    <p>Back <a href="home.html" th:href="@{/}">HOME</a></p>
+    <hr />
+    <h1>Manage Permissions</h1>
+    <table>
+      <tr>
+        <th>Name</th>
+        <th>Status</th>
+        <th>Granted</th>
+        <th>Decliend</th>
+      </tr>
+      <tr th:each="permission : ${permissions}">
+        <td th:text="${permission.name}">public_profile</td>
+        <td th:text="${permission.status}">granted</td>
+        <td th:text="${permission.granted}">true</td>
+        <td th:text="${permission.declined}">false</td>
+      </tr>
+    </table>
+    <form action="#" th:action="@{/permissions.html}" method="POST">
+      <input type="text" name="scope" />
+      <input type="submit" value="Request permission" />
+    </form>
+  </body>
+</html>