Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Feb 11, 2019
2 parents d3a689d + 7ebfe7a commit aadb716
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
17 changes: 17 additions & 0 deletions doc/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 27 additions & 1 deletion src/controllers/session-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/css/scrumonline.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ footer {
div.row.topic {
margin-bottom: 20px;
}
button.wipe {
margin-top: 10.75px;
}
div.topic .form-control {
width: 280px;
}
Expand Down
11 changes: 11 additions & 0 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions src/templates/master.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
?>
<!-- Headline -->
<div class="row">
<div class="col-sm-10 col-md-11">
<div class="col-xs-12 col-sm-1">
<button class="btn btn-lg btn-danger wipe" ng-click="master.wipe()">Wipe</button>
</div>
<div class="col-xs-10 col-sm-8 col-md-10">
<h1>{{ master.id }} - {{ master.name }}</h1>
</div>
<div class="hidden-xs col-sm-2 col-md-1">
Expand Down Expand Up @@ -67,7 +70,7 @@
<!-- Team list and complete button -->
<div class="col-xs-12 col-md-5" ng-if="!master.teamComplete">
<h2>Team</h2>
<il class="list-group">
<ul class="list-group">
<!-- Iterate over votes as they represent members as well -->
<li class="list-group-item" ng-repeat="member in master.votes track by member.id">{{$index + 1}}. {{member.name}}</li>
</ul>
Expand Down

0 comments on commit aadb716

Please sign in to comment.