aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2014-10-07 07:51:07 +0200
committerChristian Weiske <cweiske@cweiske.de>2014-10-07 07:51:07 +0200
commitace226e665fa77d04a61dfd61818f6cce5df6861 (patch)
tree1008ad783d7e94249cf4b4103e41ecdf25ba2591
parentb77c4b6b2de74543d9543139a1d2b3c4fe2f592f (diff)
downloadgrauphel-ace226e665fa77d04a61dfd61818f6cce5df6861.tar.gz
grauphel-ace226e665fa77d04a61dfd61818f6cce5df6861.zip
Deleting tokens works (without confirmation)
-rw-r--r--appinfo/application.php2
-rw-r--r--appinfo/routes.php5
-rw-r--r--controller/guicontroller.php1
-rw-r--r--controller/tokencontroller.php28
-rw-r--r--grauphel.css17
-rw-r--r--templates/tokens.php10
6 files changed, 58 insertions, 5 deletions
diff --git a/appinfo/application.php b/appinfo/application.php
index 20325de..66ed557 100644
--- a/appinfo/application.php
+++ b/appinfo/application.php
@@ -59,6 +59,8 @@ class Application extends App
$container->registerService(
'TokenController',
function($c) {
+ Dependencies::get()->urlGen
+ = $c->query('ServerContainer')->getURLGenerator();
return new \OCA\Grauphel\Controller\TokenController(
$c->query('AppName'),
$c->query('Request'),
diff --git a/appinfo/routes.php b/appinfo/routes.php
index a730583..28ba16d 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -79,6 +79,11 @@ $application->registerRoutes(
'name' => 'token#delete',
'verb' => 'DELETE',
),
+ array(
+ 'url' => '/tokens/{username}/{tokenKey}',
+ 'name' => 'token#deletePost',
+ 'verb' => 'POST',
+ ),
)
)
);
diff --git a/controller/guicontroller.php b/controller/guicontroller.php
index 0cb8e91..58768f2 100644
--- a/controller/guicontroller.php
+++ b/controller/guicontroller.php
@@ -111,6 +111,7 @@ class GuiController extends Controller
$this->user->getUid(), 'access'
),
'client' => new Client(),
+ 'username' => $this->user->getUid(),
)
);
$this->addNavigation($res, null);
diff --git a/controller/tokencontroller.php b/controller/tokencontroller.php
index 97d142a..acc9238 100644
--- a/controller/tokencontroller.php
+++ b/controller/tokencontroller.php
@@ -14,6 +14,7 @@
namespace OCA\Grauphel\Controller;
use \OCP\AppFramework\Controller;
+use \OCP\AppFramework\Http\RedirectResponse;
use \OCA\Grauphel\Lib\Dependencies;
use \OCA\Grauphel\Lib\OAuthException;
use \OCA\Grauphel\Lib\Response\ErrorResponse;
@@ -41,7 +42,8 @@ class TokenController extends Controller
public function __construct($appName, \OCP\IRequest $request, $user)
{
parent::__construct($appName, $request);
- $this->user = $user;
+ $this->user = $user;
+ $this->deps = Dependencies::get();
//default http header: we assume something is broken
header('HTTP/1.0 500 Internal Server Error');
@@ -49,7 +51,7 @@ class TokenController extends Controller
/**
- * Delete access tokens
+ * Delete an access token
* DELETE /tokens/$username/$tokenKey
*
* @NoAdminRequired
@@ -84,5 +86,27 @@ class TokenController extends Controller
$res->setStatus(\OCP\AppFramework\Http::STATUS_NO_CONTENT);
return $res;
}
+
+ /**
+ * Delete an access token via POST
+ * POST /tokens/$username/$tokenKey
+ *
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ */
+ public function deletePost($username, $tokenKey)
+ {
+ if (isset($_POST['delete']) && $_POST['delete'] == 1) {
+ $this->delete($username, $tokenKey);
+ }
+
+ $res = new RedirectResponse(
+ $this->deps->urlGen->getAbsoluteURL(
+ $this->deps->urlGen->linkToRoute('grauphel.gui.tokens')
+ )
+ );
+ $res->setStatus(\OCP\AppFramework\Http::STATUS_FOUND);
+ return $res;
+ }
}
?>
diff --git a/grauphel.css b/grauphel.css
index 85143f7..21c44d4 100644
--- a/grauphel.css
+++ b/grauphel.css
@@ -115,3 +115,20 @@ table.table td {
background-position: 8px center;
background-repeat: no-repeat;
}
+
+a.action.delete, table.table form button.action.delete {
+ position: absolute;
+ right: 0px;
+ padding: 17px 14px;
+ padding: 3px 14px;
+}
+a.action {
+ line-height: 30px;
+}
+table.table form {
+ display: inline;
+}
+table.table form button.action {
+ border: none;
+ background-color: transparent;
+}
diff --git a/templates/tokens.php b/templates/tokens.php
index 7707516..48e5998 100644
--- a/templates/tokens.php
+++ b/templates/tokens.php
@@ -11,7 +11,6 @@
<th>Token</th>
<th>Client</th>
<th>Last use</th>
- <th>Actions</th>
</tr>
</thead>
<tbody>
@@ -19,8 +18,13 @@
<tr>
<td><?php p($token->tokenKey); ?></td>
<td title="<?php p($token->client); ?>"><?php p($_['client']->getNiceName($token->client)); ?></td>
- <td><?php p(\OCP\Util::formatDate($token->lastuse)); ?></td>
- <td>Disable Delete</td>
+ <td>
+ <?php p(\OCP\Util::formatDate($token->lastuse)); ?>
+ <form method="POST" action="<?php p(OCP\Util::linkToRoute('grauphel.token.delete', array('username' => $_['username'], 'tokenKey' => $token->tokenKey))); ?>">
+ <input type="hidden" name="delete" value="1" />
+ <button type="submit" class="icon-delete delete action" original-title="Delete"/>
+ </form>
+ </td>
</tr>
<?php } ?>
</tbody>