Skip to content

Commit

Permalink
rm phone num from login link
Browse files Browse the repository at this point in the history
  • Loading branch information
jho44 committed Jan 7, 2024
1 parent 5d17c91 commit edbd081
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/lib/server/twilio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ const msgToSend = async (
const localTime = toLocalTimezone(magicLink.expires, timeZone).toLocaleString(
DateTime.TIME_SIMPLE
);
msg = `Your login link to playdate.help will expire at ${localTime}: ${url}/login/${phone.slice(
1
)}/${token}`;
msg = `Your login link to playdate.help will expire at ${localTime}: ${url}/login/${token}`;
break;
}
case 'circleNotif': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { redirect } from '@sveltejs/kit';
import prisma from '$lib/prisma';

export const load = (async ({ params, cookies, setHeaders }) => {
console.log('LOAD LOGIN');
let magicLinkInfo;
try {
// validate token against what's stored in the DB
Expand All @@ -16,23 +15,22 @@ export const load = (async ({ params, cookies, setHeaders }) => {
if (!magicLinkInfo) throw Error;
} catch {
console.error(`Can't verify token ${params.token} for phone ${params.phone}`);
throw redirect(308, `/?phone=${params.phone}&status=403`);
throw redirect(308, `/?phone=${cookies.get('phone')}&status=403`);
}

// check DB's expiration date
const { phone, expires } = magicLinkInfo as { phone: string; expires: Date };

if (expires < new Date()) {
console.error('Token has expired');
throw redirect(308, `/?phone=${params.phone}&status=403`);
throw redirect(308, `/?phone=${phone}&status=403`);
}

let crypto;
try {
crypto = await import('node:crypto');
} catch (err) {
console.error('crypto support is disabled!');
throw redirect(308, `/?phone=${params.phone}&status=500`);
throw redirect(308, `/?phone=${phone}&status=500`);
}

const sessionCreatedAt = new Date();
Expand All @@ -57,7 +55,6 @@ export const load = (async ({ params, cookies, setHeaders }) => {
createdAt: sessionCreatedAt
}
});
console.log('CREATED SESSION', session);

setHeaders({
'cache-control': 'no-store, max-age=0'
Expand Down
File renamed without changes.

0 comments on commit edbd081

Please sign in to comment.