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..d918734 100644 --- a/src/controllers/session-controller.php +++ b/src/controllers/session-controller.php @@ -185,7 +185,12 @@ public function requiresPassword($id = 0) // URL: /api/session/membercheck/{id}/{mid} public function membercheck($sid, $mid) { - $session = $this->getSession($sid); + try{ + $session = $this->getSession($sid); + } + catch(Exception $e){ + return new BoolResponse(); + } foreach($session->getMembers() as $member) { if($member->getId() == $mid) { return new BoolResponse(true); @@ -224,6 +229,27 @@ 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; + // Clear and wipe polls + $session->setCurrentPoll(null); + foreach($session->getPolls() as $poll) + $this->entityManager->remove($poll); + // Wipe all members + foreach($session->getMembers() as $member) + $this->entityManager->remove($member); + $this->entityManager->flush(); + // Remove session object + $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 }}