alpha testing feature flag

This commit is contained in:
jackiettran
2025-10-30 16:16:27 -04:00
parent ee3a6fd8e1
commit 71ce2c63fb
4 changed files with 51 additions and 30 deletions

View File

@@ -66,31 +66,33 @@ router.post(
// Alpha access validation
let alphaInvitation = null;
if (req.signedCookies && req.signedCookies.alphaAccessCode) {
const { code } = req.signedCookies.alphaAccessCode;
if (code) {
alphaInvitation = await AlphaInvitation.findOne({
where: { code },
});
if (!alphaInvitation) {
return res.status(403).json({
error: "Invalid alpha access code",
if (process.env.ALPHA_TESTING_ENABLED === 'true') {
if (req.cookies && req.cookies.alphaAccessCode) {
const { code } = req.cookies.alphaAccessCode;
if (code) {
alphaInvitation = await AlphaInvitation.findOne({
where: { code },
});
}
if (alphaInvitation.status === "revoked") {
return res.status(403).json({
error: "This alpha access code is no longer valid",
});
if (!alphaInvitation) {
return res.status(403).json({
error: "Invalid alpha access code",
});
}
if (alphaInvitation.status === "revoked") {
return res.status(403).json({
error: "This alpha access code is no longer valid",
});
}
}
}
}
if (!alphaInvitation) {
return res.status(403).json({
error: "Alpha access required. Please enter your invitation code first.",
});
if (!alphaInvitation) {
return res.status(403).json({
error: "Alpha access required. Please enter your invitation code first.",
});
}
}
const user = await User.create({
@@ -356,17 +358,19 @@ router.post(
});
// Check if there's an alpha invitation for this email
const alphaInvitation = await AlphaInvitation.findOne({
where: { email: email.toLowerCase().trim() },
});
if (alphaInvitation && !alphaInvitation.usedBy) {
// Link invitation to new user
await alphaInvitation.update({
usedBy: user.id,
usedAt: new Date(),
status: "active",
if (process.env.ALPHA_TESTING_ENABLED === 'true') {
const alphaInvitation = await AlphaInvitation.findOne({
where: { email: email.toLowerCase().trim() },
});
if (alphaInvitation && !alphaInvitation.usedBy) {
// Link invitation to new user
await alphaInvitation.update({
usedBy: user.id,
usedAt: new Date(),
status: "active",
});
}
}
}