import java.util.List;
import javax.inject.Inject;
+import org.springframework.social.connect.ConnectionFactoryLocator;
+import org.springframework.social.connect.ConnectionRepository;
+import org.springframework.social.connect.web.ConnectController;
import org.springframework.social.facebook.api.Facebook;
import org.springframework.social.facebook.api.Permission;
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.RedirectView;
/**
* @author Kai Moritz
*/
@Controller
-public class PermissionsController
+@RequestMapping("/permissions.html")
+public class PermissionsController extends ConnectController
{
private final Facebook facebook;
@Inject
- public PermissionsController(Facebook facebook)
+ public PermissionsController(
+ ConnectionFactoryLocator connectionFactoryLocator,
+ ConnectionRepository connectionRepository,
+ Facebook facebook
+ )
{
+ super(connectionFactoryLocator, connectionRepository);
this.facebook = facebook;
}
- @RequestMapping(value = "/permissions.html", method = RequestMethod.GET)
- public String list(Model model)
+ @Override
+ public String connectionStatus(NativeWebRequest request, Model model)
{
List<Permission> permissions = facebook.userOperations().getUserPermissions();
model.addAttribute("permissions", permissions);
return "permissions";
}
+
+ @RequestMapping(method=RequestMethod.POST)
+ public RedirectView connect(NativeWebRequest request)
+ {
+ return super.connect("facebook", request);
+ }
+
+ @Override
+ protected RedirectView connectionStatusRedirect(
+ String providerId,
+ NativeWebRequest request
+ )
+ {
+ return new RedirectView("/permissions.html", true);
+ }
}