$container->registerService(
'TokenController',
function($c) {
+ Dependencies::get()->urlGen
+ = $c->query('ServerContainer')->getURLGenerator();
return new \OCA\Grauphel\Controller\TokenController(
$c->query('AppName'),
$c->query('Request'),
'name' => 'token#delete',
'verb' => 'DELETE',
),
+ array(
+ 'url' => '/tokens/{username}/{tokenKey}',
+ 'name' => 'token#deletePost',
+ 'verb' => 'POST',
+ ),
)
)
);
$this->user->getUid(), 'access'
),
'client' => new Client(),
+ 'username' => $this->user->getUid(),
)
);
$this->addNavigation($res, null);
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;
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');
/**
- * Delete access tokens
+ * Delete an access token
* DELETE /tokens/$username/$tokenKey
*
* @NoAdminRequired
$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;
+ }
}
?>
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;
+}
<th>Token</th>
<th>Client</th>
<th>Last use</th>
- <th>Actions</th>
</tr>
</thead>
<tbody>
<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>