diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2014-08-18 23:54:32 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2014-08-18 23:54:32 +0200 |
| commit | db2f09d46ce2f3a46be1b6f6e031492966242025 (patch) | |
| tree | 4e22eba650c022936a4071afd9b2b0ee417ad34b /controller/accesscontroller.php | |
| parent | 3780cf15a59c48b3d71e8ec27e3bdacd8a119460 (diff) | |
| download | grauphel-db2f09d46ce2f3a46be1b6f6e031492966242025.tar.gz grauphel-db2f09d46ce2f3a46be1b6f6e031492966242025.zip | |
oauth dance works
Diffstat (limited to 'controller/accesscontroller.php')
| -rw-r--r-- | controller/accesscontroller.php | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/controller/accesscontroller.php b/controller/accesscontroller.php deleted file mode 100644 index 68789b7..0000000 --- a/controller/accesscontroller.php +++ /dev/null @@ -1,145 +0,0 @@ -<?php -/** - * Part of grauphel - * - * PHP version 5 - * - * @category Tools - * @package Grauphel - * @author Christian Weiske <cweiske@cweiske.de> - * @copyright 2014 Christian Weiske - * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 - * @link http://cweiske.de/grauphel.htm - */ -namespace OCA\Grauphel\Controller; -use \OCP\AppFramework\Controller; - -/** - * Login and authorization handling - * - * @category Tools - * @package Grauphel - * @author Christian Weiske <cweiske@cweiske.de> - * @copyright 2014 Christian Weiske - * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 - * @version Release: @package_version@ - * @link http://cweiske.de/grauphel.htm - */ -class AccessController extends Controller -{ - public function login($returnUrl = null) - { - $returnUrl = $this->loadReturnUrl($returnUrl); - - if (isset($_POST['user']) && trim($_POST['user']) != '') { - $this->deps->frontend->setUser(trim($_POST['user'])); - header('Location: ' . $returnUrl); - exit(0); - } - - $hFormUrl = htmlspecialchars( - $this->deps->urlGen->addParams( - $this->deps->urlGen->accessLogin(), - array('returnurl' => $returnUrl) - ) - ); - //FIXME: do some real login - header('HTTP/1.0 200 OK'); - - echo <<<HTM -<html> - <head> - <title>grauphel login</title> - </head> - <body> - <form method="post" action="$hFormUrl"> - <p> - Log into <em>grauphel</em>: - </p> - <label> - User name: - <input id="user" type="text" name="user" size="20" value=""/> - </label> - <input type="submit" value="Login" /> - </form> - <script type="text/javascript"> -//FIXME -/* -document.getElementById('user').value = 'cweiske'; -document.forms[0].submit(); -/**/ - </script> - </body> -</html> -HTM; - exit(0); - } - - public function authorize($returnUrl = null) - { - var_dump('asd');die(); - $returnUrl = $this->loadReturnUrl($returnUrl); - - if (isset($_POST['auth'])) { - if ($_POST['auth'] == 'ok') { - $this->deps->frontend->setAuth(true); - } else if ($_POST['auth'] == 'cancel') { - $this->deps->frontend->setAuth(false); - } - header('Location: ' . $returnUrl); - exit(0); - } - - header('HTTP/1.0 200 OK'); - $hFormUrl = htmlspecialchars( - $this->deps->urlGen->addParams( - $this->deps->urlGen->accessAuthorize(), - array('returnurl' => $returnUrl) - ) - ); - - echo <<<HTM -<html> - <head> - <title>grauphel authorization</title> - </head> - <body> - <form method="post" action="$hFormUrl"> - <p> - Shall application FIXME get full access to the notes? - </p> - <button type="submit" name="auth" value="ok">Yes, authorize</button> - <button type="submit" name="auth" value="cancel">No, decline</button> - </body> -</html> -HTM; - exit(0); - } - - protected function loadReturnUrl($returnUrl = null) - { - if ($returnUrl === null) { - if (isset($_GET['returnurl'])) { - $returnUrl = $_GET['returnurl']; - } else { - $returnUrl = $this->deps->urlGen->index(); - } - } - return $returnUrl; - } - - /** - * @NoAdminRequired - * @NoCSRFRequired - * @PublicPage - */ - public function test() - { - var_dump('asd');die(); - $this->registerResponder('xml', function($value) { - return new XMLResponse($value); - }); - return array('foo' => 'bar'); - } -} -?> |
