Skip to content

Commit

Permalink
Passkey timetolive and ics day error (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
hingobway authored Sep 18, 2024
1 parent a404163 commit 7d7a4be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions server/src/auth/passkeys.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EMAIL_LOGIN_EXPIRE } from '@@/CONSTANTS';
import { emails } from '@@/email';
import { isDev, siteDomain } from '@@/util/dev';
import { siteDomain } from '@@/util/dev';
import { PasswordlessClient } from '@passwordlessdev/passwordless-nodejs';
import axios from 'axios';
import qs from 'qs';
Expand Down Expand Up @@ -33,10 +33,10 @@ export async function passwordlessSendMagicLink(p: {
const { data } = await axios
.post(
PASSWORDLESS_API + '/signin/generate-token',
{ userId: params.userId },
{ userId: params.userId, timeToLive: EMAIL_LOGIN_EXPIRE },
{ headers: { ApiSecret: PASSWORDLESS_SECRET } }
)
.catch(() => ({ data: null }));
.catch((e) => ({ data: console.log(new Error(e)) }));
if (!data?.token) throw new Error();

const url = params.urlTemplate.replace('$TOKEN', data.token);
Expand Down
7 changes: 4 additions & 3 deletions server/src/ics/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function makeICS() {
event.uid = `${stay.id}@elmpoint.org`;
event.summary = stay.title;
event.startDate = getICALTime(stay.dateStart);
event.endDate = getICALTime(stay.dateEnd);
event.endDate = getICALTime(stay.dateEnd, /* plusOne = */ true);
event.description = stay.description + autoDescription(stay);
if (stay.reservations.length && stay.reservations[0].room) {
const room = stay.reservations[0].room;
Expand Down Expand Up @@ -166,8 +166,9 @@ function roomText(room: ICSRoom) {
: `${room?.text}`;
}

function getICALTime(ts: number) {
const d = dateTSObject(ts).add(1, 'day');
function getICALTime(ts: number, plusOne?: boolean) {
let d = dateTSObject(ts);
if (plusOne) d = d.add(1, 'day');
return new ical.Time({
isDate: true,
year: d.year(),
Expand Down

0 comments on commit 7d7a4be

Please sign in to comment.