Skip to content

Commit

Permalink
directLinkPrivate 1 hour
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronshiel committed Feb 7, 2024
1 parent 9cc453e commit afeb79a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion node/src/gql/query/mentor-client-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ function verifyDirectLinkSecure(
const currentTime = new Date();
const timeDiff = currentTime.getTime() - leftHomePage.getTime();
const secondsDiff = timeDiff / 1000;
return secondsDiff <= 60;
const hoursDiff = secondsDiff / 3600;
return hoursDiff <= 1;
}

export const mentorData = {
Expand Down
22 changes: 11 additions & 11 deletions node/test/graphql/query/mentor-client-data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,10 @@ describe('mentorClientData', () => {
);
});

it('Rejects if home page visited more than 1 minute ago', async () => {
const fiveMinutesAgoTime = new Date();
fiveMinutesAgoTime.setMinutes(fiveMinutesAgoTime.getMinutes() - 5);
const timeInPast = fiveMinutesAgoTime.toISOString();
it('Rejects if home page visited more than 1 hour ago', async () => {
const twoHoursAgo = new Date();
twoHoursAgo.setHours(twoHoursAgo.getHours() - 2);
const timeInPast = twoHoursAgo.toISOString();
const response = await request(app)
.post('/graphql')
.send({
Expand All @@ -337,9 +337,9 @@ describe('mentorClientData', () => {

it('Does not reject despite visited time if user owns mentor', async () => {
const token = getToken('5ffdf41a1ee2c62320b49ea2');
const fiveMinutesAgoTime = new Date();
fiveMinutesAgoTime.setMinutes(fiveMinutesAgoTime.getMinutes() - 5);
const timeInPast = fiveMinutesAgoTime.toISOString();
const twoHoursAgo = new Date();
twoHoursAgo.setHours(twoHoursAgo.getHours() - 2);
const timeInPast = twoHoursAgo.toISOString();
const response = await request(app)
.post('/graphql')
.set('Authorization', `bearer ${token}`)
Expand All @@ -360,9 +360,9 @@ describe('mentorClientData', () => {

it('Does not reject despite visited time if user is admin', async () => {
const token = getToken('5ffdf41a1ee2c62320b49ea6');
const fiveMinutesAgoTime = new Date();
fiveMinutesAgoTime.setMinutes(fiveMinutesAgoTime.getMinutes() - 5);
const timeInPast = fiveMinutesAgoTime.toISOString();
const twoHoursAgo = new Date();
twoHoursAgo.setHours(twoHoursAgo.getHours() - 2);
const timeInPast = twoHoursAgo.toISOString();
const response = await request(app)
.post('/graphql')
.set('Authorization', `bearer ${token}`)
Expand All @@ -381,7 +381,7 @@ describe('mentorClientData', () => {
});
});

it('returns mentor if home page visited within last minute', async () => {
it('returns mentor if home page visited within last hour', async () => {
const now = new Date();
const response = await request(app)
.post('/graphql')
Expand Down

0 comments on commit afeb79a

Please sign in to comment.