9 * @author Christian Weiske <cweiske@cweiske.de>
10 * @copyright 2014 Christian Weiske
11 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
12 * @link http://cweiske.de/grauphel.htm
14 namespace OCA\Grauphel\Controller;
15 use \OCP\AppFramework\Controller;
18 * Login and authorization handling
22 * @author Christian Weiske <cweiske@cweiske.de>
23 * @copyright 2014 Christian Weiske
24 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
25 * @version Release: @package_version@
26 * @link http://cweiske.de/grauphel.htm
28 class AccessController extends Controller
30 public function login($returnUrl = null)
32 $returnUrl = $this->loadReturnUrl($returnUrl);
34 if (isset($_POST['user']) && trim($_POST['user']) != '') {
35 $this->deps->frontend->setUser(trim($_POST['user']));
36 header('Location: ' . $returnUrl);
40 $hFormUrl = htmlspecialchars(
41 $this->deps->urlGen->addParams(
42 $this->deps->urlGen->accessLogin(),
43 array('returnurl' => $returnUrl)
46 //FIXME: do some real login
47 header('HTTP/1.0 200 OK');
52 <title>grauphel login</title>
55 <form method="post" action="$hFormUrl">
57 Log into <em>grauphel</em>:
61 <input id="user" type="text" name="user" size="20" value=""/>
63 <input type="submit" value="Login" />
65 <script type="text/javascript">
68 document.getElementById('user').value = 'cweiske';
69 document.forms[0].submit();
78 public function authorize($returnUrl = null)
80 var_dump('asd');die();
81 $returnUrl = $this->loadReturnUrl($returnUrl);
83 if (isset($_POST['auth'])) {
84 if ($_POST['auth'] == 'ok') {
85 $this->deps->frontend->setAuth(true);
86 } else if ($_POST['auth'] == 'cancel') {
87 $this->deps->frontend->setAuth(false);
89 header('Location: ' . $returnUrl);
93 header('HTTP/1.0 200 OK');
94 $hFormUrl = htmlspecialchars(
95 $this->deps->urlGen->addParams(
96 $this->deps->urlGen->accessAuthorize(),
97 array('returnurl' => $returnUrl)
104 <title>grauphel authorization</title>
107 <form method="post" action="$hFormUrl">
109 Shall application FIXME get full access to the notes?
111 <button type="submit" name="auth" value="ok">Yes, authorize</button>
112 <button type="submit" name="auth" value="cancel">No, decline</button>
119 protected function loadReturnUrl($returnUrl = null)
121 if ($returnUrl === null) {
122 if (isset($_GET['returnurl'])) {
123 $returnUrl = $_GET['returnurl'];
125 $returnUrl = $this->deps->urlGen->index();
136 public function test()
138 var_dump('asd');die();
139 $this->registerResponder('xml', function($value) {
140 return new XMLResponse($value);
142 return array('foo' => 'bar');