From 12dbde13dc4eeeeea1478a3f3cc03f6e32876d67 Mon Sep 17 00:00:00 2001 From: Toxantron Date: Sun, 10 Feb 2019 14:37:42 +0100 Subject: [PATCH] Offer wipe option for session --- doc/swagger.yaml | 17 +++++++++++++++++ src/controllers/session-controller.php | 13 +++++++++++++ src/css/scrumonline.css | 3 +++ src/js/main.js | 11 +++++++++++ src/templates/master.php | 7 +++++-- 5 files changed, 49 insertions(+), 2 deletions(-) diff --git a/doc/swagger.yaml b/doc/swagger.yaml index f7f893b..87c6be4 100644 --- a/doc/swagger.yaml +++ b/doc/swagger.yaml @@ -214,6 +214,23 @@ paths: type: array items: type: string + '/session/wipe/{id}': + get: + tags: + - session + summary: Wipe the session and all associated data + produces: + - application/json + parameters: + - name: id + in: path + required: true + type: integer + format: int64 + description: Id of the session + responses: + '200': + description: Session was wiped '/poll/vote/{id}/{mid}': post: tags: diff --git a/src/controllers/session-controller.php b/src/controllers/session-controller.php index 44123c9..692fea0 100644 --- a/src/controllers/session-controller.php +++ b/src/controllers/session-controller.php @@ -224,6 +224,19 @@ public function cardsets() return $this->cardSets; } + // Wipe all data from the session + // URL: /api/session/wipe/{id} + public function wipe($id) + { + // Fetch session and verify token + $session = $this->getSession($id); + if (!$this->verifyToken($session)) + return; + // Remove session and wipe + $this->entityManager->remove($session); + $this->entityManager->flush(); + } + // Set the token cookie for this session // with additional parameters for expiration and path private function setCookie($session, $token = null) diff --git a/src/css/scrumonline.css b/src/css/scrumonline.css index 228c825..94f0d63 100644 --- a/src/css/scrumonline.css +++ b/src/css/scrumonline.css @@ -43,6 +43,9 @@ footer { div.row.topic { margin-bottom: 20px; } +button.wipe { + margin-top: 10.75px; +} div.topic .form-control { width: 280px; } diff --git a/src/js/main.js b/src/js/main.js index ac634d6..c5c670d 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -340,6 +340,17 @@ scrum.app.controller('MasterController', function ($http, $routeParams, $locatio this.remove = function (id) { $http.delete("/api/session/member/" + self.id + "/" + id); }; + + // Wipe the session and redirect + this.wipe = function () { + var confirmed = confirm("Do you want to delete the session and wipe all associated data?"); + if (!confirmed) + return; + + $http.delete('/api/session/wipe/' + self.id).then(function (response){ + $location.url("/404.html"); // Redirect to 404 when we wiped the session + }); + } // Select a ticketing system this.selectSource = function(source) { diff --git a/src/templates/master.php b/src/templates/master.php index cba5d4b..c97a1d9 100644 --- a/src/templates/master.php +++ b/src/templates/master.php @@ -4,7 +4,10 @@ ?>
-
+
+ +
+

{{ master.id }} - {{ master.name }}