Skip to content

Commit

Permalink
Merge pull request #440 from roy-zahor/gate_system
Browse files Browse the repository at this point in the history
Gate data integrity check
  • Loading branch information
roy-zahor authored May 22, 2017
2 parents 7f9c135 + 9403de7 commit 9311966
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions routes/api_gate_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var drupalSync = require('../scripts/drupal_ticket_sync');
var Ticket = require('../models/ticket').Ticket;
var Event = require('../models/event').Event;
var UsersGroup = require('../models/user').UsersGroup;
var UsersGroupMembership = require('../models/user').UsersGroupMembership;

const ERRORS = {
GATE_CODE_MISSING: 'gate_code is missing or incorrect',
Expand Down Expand Up @@ -155,6 +156,13 @@ router.post('/gate-enter', async function (req, res) {
if (!group) {
return sendError(res, 500, "TICKET_NOT_IN_GROUP");
}

let groupMembership = await UsersGroupMembership.forge({group_id: req.body.group_id, user_id: ticket.attributes.holder_id}).fetch();

if (!groupMembership) {
return sendError(res, 500, "TICKET_NOT_IN_GROUP");
}

if (await group.quotaReached) {
return sendError(res, 500, "QUOTA_REACHED");
}
Expand Down

0 comments on commit 9311966

Please sign in to comment.