mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-17 16:37:43 +00:00
fix(passkey): skip email verification in TEST_MODE for passkey registration
When TEST_MODE is enabled with autoVerifyUsers, passkey registration now auto-verifies users immediately instead of sending verification emails. This enables local development without SMTP configuration.
This commit is contained in:
parent
c576372d00
commit
e924b068ac
1 changed files with 19 additions and 1 deletions
|
|
@ -15,6 +15,7 @@ import { Logger } from './logger';
|
|||
import { randomBytes } from 'crypto';
|
||||
import { sendPasskeyRecoveryEmail } from './email';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { loadConfigFromEnv } from './config';
|
||||
|
||||
// Constants
|
||||
const CHALLENGE_EXPIRY_MS = 5 * 60 * 1000; // 5 minutes
|
||||
|
|
@ -240,7 +241,24 @@ export const verifyRegistration = async (
|
|||
Logger.info(`Created new passkey user for ${email}`);
|
||||
}
|
||||
|
||||
// Send verification email
|
||||
// In TEST_MODE with autoVerifyUsers, skip email and auto-verify
|
||||
const config = loadConfigFromEnv();
|
||||
if (config.testMode?.autoVerifyUsers) {
|
||||
await prisma.user.update({
|
||||
where: { email: email.toLowerCase() },
|
||||
data: {
|
||||
isVerified: 1,
|
||||
verificationToken: null,
|
||||
verificationTokenExpiresAt: null,
|
||||
},
|
||||
});
|
||||
Logger.info(`[TEST_MODE] Auto-verified passkey user: ${email}`);
|
||||
return {
|
||||
message: 'Registration successful. Your account has been automatically verified.',
|
||||
};
|
||||
}
|
||||
|
||||
// Normal flow: send verification email
|
||||
const { sendVerificationEmail } = await import('./email');
|
||||
const emailSent = await sendVerificationEmail(email, verificationToken);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue