Skip to content

Commit 71f6854

Browse files
committed
feat: magic links
1 parent e3360f8 commit 71f6854

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/controllers/authentication.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const AUTH_MODE = process.env.AUTH_MODE;
3636

3737
export const login = async (req: Request, res: Response) => {
3838
// For the initial login step, user either passes in an email or a phone number
39-
const { identifier } = req.body;
39+
const { identifier, passkeyAvailable } = req.body;
4040
let user, identifierType;
4141

4242
if (!identifier) {
@@ -142,7 +142,7 @@ export const login = async (req: Request, res: Response) => {
142142

143143
const credential = await Credential.findOne({ where: { userId: user.id } });
144144

145-
if (!credential) {
145+
if (passkeyAvailable && !credential) {
146146
logger.error(`Login attempt for a verified users, but no passkey. ${identifier}`);
147147
await AuthEvent.create({
148148
user_id: user.id,

src/routes/magicLink.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ router.get(
2222
requestMagicLink,
2323
);
2424

25-
router.get('/poll', attachAuthMiddleware('ephemeral'), pollMagicLinkConfirmation);
25+
router.get('/check', attachAuthMiddleware('ephemeral'), pollMagicLinkConfirmation);
2626
router.get('/verify/:token', verifyMagicLink);
2727

2828
export default router;

src/services/messagingService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const sendOTPSMS = async (to: string, token: number) => {
2525
};
2626

2727
export const sendMagicLinkEmail = async (to: string, token: string, safeRedirect: string) => {
28-
logger.debug(`Sedning magic link to: ${to}. URL: ${safeRedirect}`);
28+
logger.debug(`Sending magic link to: ${to}. URL: ${safeRedirect}`);
2929

3030
if (isDevelopment) {
3131
return;

0 commit comments

Comments
 (0)