diff --git a/app/models/Invite.js b/app/models/Invite.js index a558cbc..d5228e9 100644 --- a/app/models/Invite.js +++ b/app/models/Invite.js @@ -32,7 +32,7 @@ var InviteSchema = mongoose.Schema({ default: null }, - exp: { + expires: { type: Date, default: null } diff --git a/app/models/User.js b/app/models/User.js index 110b4cb..d008d5b 100644 --- a/app/models/User.js +++ b/app/models/User.js @@ -29,6 +29,11 @@ var UserSchema = mongoose.Schema({ default: 0 }, + inviteCount: { + type: Number, + default: 0 + }, + date: { type: Date, default: Date.now diff --git a/app/routes/auth.js b/app/routes/auth.js index df94970..ebeaaed 100644 --- a/app/routes/auth.js +++ b/app/routes/auth.js @@ -55,7 +55,7 @@ async function validateInvite(code) { if (invite.used) return {valid: false, message: 'Invite already used.'}; - if (invite.exp != null && invite.exp < Date.now()) + if (invite.expires != null && invite.expires < Date.now()) return {valid: false, message: 'Invite expired.'}; return {valid: true, invite: invite}; diff --git a/test/api.js b/test/api.js index 7b884ed..4c1e2b1 100644 --- a/test/api.js +++ b/test/api.js @@ -30,7 +30,7 @@ after(() => { server.close(); }); -describe('Accounts', function() { +describe('Authentication', function() { beforeEach(async () => util.clearDatabase()); describe('/POST register', () => { @@ -87,7 +87,7 @@ describe('Accounts', function() { ); it('MUST NOT register an expired invite', async () => - verifyRejectedInvite({code: 'code', exp: new Date(), issuer: 'Mocha'}, 'Invite expired.') + verifyRejectedInvite({code: 'code', expires: new Date(), issuer: 'Mocha'}, 'Invite expired.') ); }); @@ -192,7 +192,7 @@ describe('Accounts', function() { }); }); -describe('Uploads', () => { +describe('Uploading', () => { beforeEach(async () => util.clearDatabase()); describe('/POST upload', () => {