1
0
mirror of https://github.com/Foltik/Shimapan synced 2025-01-07 08:42:49 -05:00

Change exp field to expires

This commit is contained in:
Jack Foltz 2018-07-27 14:23:23 -04:00
parent 230f9c2415
commit c9e250a68e
Signed by: foltik
GPG Key ID: 303F88F996E95541
4 changed files with 10 additions and 5 deletions

View File

@ -32,7 +32,7 @@ var InviteSchema = mongoose.Schema({
default: null default: null
}, },
exp: { expires: {
type: Date, type: Date,
default: null default: null
} }

View File

@ -29,6 +29,11 @@ var UserSchema = mongoose.Schema({
default: 0 default: 0
}, },
inviteCount: {
type: Number,
default: 0
},
date: { date: {
type: Date, type: Date,
default: Date.now default: Date.now

View File

@ -55,7 +55,7 @@ async function validateInvite(code) {
if (invite.used) if (invite.used)
return {valid: false, message: 'Invite already 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: false, message: 'Invite expired.'};
return {valid: true, invite: invite}; return {valid: true, invite: invite};

View File

@ -30,7 +30,7 @@ after(() => {
server.close(); server.close();
}); });
describe('Accounts', function() { describe('Authentication', function() {
beforeEach(async () => util.clearDatabase()); beforeEach(async () => util.clearDatabase());
describe('/POST register', () => { describe('/POST register', () => {
@ -87,7 +87,7 @@ describe('Accounts', function() {
); );
it('MUST NOT register an expired invite', async () => 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()); beforeEach(async () => util.clearDatabase());
describe('/POST upload', () => { describe('/POST upload', () => {