Commit ac04356e61e71ed2b4920749b3af09d805773dc9
1 parent
8bb442a5
Afficher les contrôles de membre si loggué uniquement
Showing
4 changed files
with
8 additions
and
10 deletions
Show diff stats
app/controllers/sessions.js
@@ -2,10 +2,6 @@ var Session = require('../models/session'); | @@ -2,10 +2,6 @@ var Session = require('../models/session'); | ||
2 | 2 | ||
3 | var sessions = {} | 3 | var sessions = {} |
4 | 4 | ||
5 | -sessions.find = function (id, cb) { | ||
6 | - Session.findById(id, cb) | ||
7 | -} | ||
8 | - | ||
9 | sessions.valid = function (session) { | 5 | sessions.valid = function (session) { |
10 | return session.started.setSeconds(session.started.getSeconds() + 3600) > new Date() | 6 | return session.started.setSeconds(session.started.getSeconds() + 3600) > new Date() |
11 | } | 7 | } |
public/js/app.js
1 | -angular.module('ciApp', ['ngRoute', 'appRoutes', 'MembreCtrl', 'SessionsServ', 'SessionsCtrl', 'ConnectCtrl']); | ||
2 | \ No newline at end of file | 1 | \ No newline at end of file |
2 | +angular.module('ciApp', ['ngRoute', 'appRoutes', 'SessionsServ', 'SessionsCtrl', 'ConnectCtrl', 'MembreCtrl']); | ||
3 | \ No newline at end of file | 3 | \ No newline at end of file |
public/js/controllers/MembreCtrl.js
1 | -angular.module('MembreCtrl', []).controller('MembreController', ['$scope', '$http', | ||
2 | - function ($scope, $http) { | 1 | +angular.module('MembreCtrl', []).controller('MembreController', ['$scope', '$http', 'SessionService', |
2 | + function ($scope, $http, SessionService) { | ||
3 | $scope.formData = {}; | 3 | $scope.formData = {}; |
4 | + $scope.canAdd = SessionService.logged | ||
5 | + $scope.canDel = SessionService.logged | ||
4 | 6 | ||
5 | // when landing on the page, get all Membres and show them | 7 | // when landing on the page, get all Membres and show them |
6 | $http.get('/api/membres') | 8 | $http.get('/api/membres') |
public/views/membres.html
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | <th>Nom</th> | 10 | <th>Nom</th> |
11 | <th>Section</th> | 11 | <th>Section</th> |
12 | <th>Rôle</th> | 12 | <th>Rôle</th> |
13 | - <th>Action</th> | 13 | + <th ng-if="canAdd || canDel">Action</th> |
14 | </tr> | 14 | </tr> |
15 | </thead> | 15 | </thead> |
16 | <tbody ng-repeat="membre in membres"> | 16 | <tbody ng-repeat="membre in membres"> |
@@ -18,13 +18,13 @@ | @@ -18,13 +18,13 @@ | ||
18 | <td>{{ membre.login }}</td> | 18 | <td>{{ membre.login }}</td> |
19 | <td>{{ membre.section }}</td> | 19 | <td>{{ membre.section }}</td> |
20 | <td>{{ membre.role }}</td> | 20 | <td>{{ membre.role }}</td> |
21 | - <td><button type="button" class="btn btn-danger" aria-label="Expulser" ng-click="deleteMembre(membre._id)"> | 21 | + <td ng-if="canDel"><button type="button" class="btn btn-danger" aria-label="Expulser" ng-click="deleteMembre(membre._id)"> |
22 | <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> | 22 | <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> |
23 | </button> | 23 | </button> |
24 | </td> | 24 | </td> |
25 | </tr> | 25 | </tr> |
26 | </tbody> | 26 | </tbody> |
27 | - <tfoot id="membre-form"> | 27 | + <tfoot id="membre-form" ng-if="canAdd"> |
28 | <tr class="form-group"> | 28 | <tr class="form-group"> |
29 | <td> | 29 | <td> |
30 | <input type="text" class="form-control input-lg" placeholder="Login" ng-model="formData.login"> | 30 | <input type="text" class="form-control input-lg" placeholder="Login" ng-model="formData.login"> |