alpha testing feature flag
This commit is contained in:
@@ -7,6 +7,11 @@ const logger = require("../utils/logger");
|
|||||||
*/
|
*/
|
||||||
const requireAlphaAccess = async (req, res, next) => {
|
const requireAlphaAccess = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
|
// Bypass alpha access check if feature is disabled
|
||||||
|
if (process.env.ALPHA_TESTING_ENABLED !== 'true') {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
let hasAccess = false;
|
let hasAccess = false;
|
||||||
|
|
||||||
// Check 1: Valid alpha access cookie
|
// Check 1: Valid alpha access cookie
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ const router = express.Router();
|
|||||||
|
|
||||||
// Helper function to check if user has alpha access
|
// Helper function to check if user has alpha access
|
||||||
async function checkAlphaAccess(req) {
|
async function checkAlphaAccess(req) {
|
||||||
|
// Bypass alpha access check if feature is disabled
|
||||||
|
if (process.env.ALPHA_TESTING_ENABLED !== 'true') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Check 1: Valid alpha access cookie
|
// Check 1: Valid alpha access cookie
|
||||||
if (req.cookies && req.cookies.alphaAccessCode) {
|
if (req.cookies && req.cookies.alphaAccessCode) {
|
||||||
const { code } = req.cookies.alphaAccessCode;
|
const { code } = req.cookies.alphaAccessCode;
|
||||||
|
|||||||
@@ -66,8 +66,9 @@ router.post(
|
|||||||
|
|
||||||
// Alpha access validation
|
// Alpha access validation
|
||||||
let alphaInvitation = null;
|
let alphaInvitation = null;
|
||||||
if (req.signedCookies && req.signedCookies.alphaAccessCode) {
|
if (process.env.ALPHA_TESTING_ENABLED === 'true') {
|
||||||
const { code } = req.signedCookies.alphaAccessCode;
|
if (req.cookies && req.cookies.alphaAccessCode) {
|
||||||
|
const { code } = req.cookies.alphaAccessCode;
|
||||||
if (code) {
|
if (code) {
|
||||||
alphaInvitation = await AlphaInvitation.findOne({
|
alphaInvitation = await AlphaInvitation.findOne({
|
||||||
where: { code },
|
where: { code },
|
||||||
@@ -92,6 +93,7 @@ router.post(
|
|||||||
error: "Alpha access required. Please enter your invitation code first.",
|
error: "Alpha access required. Please enter your invitation code first.",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const user = await User.create({
|
const user = await User.create({
|
||||||
username,
|
username,
|
||||||
@@ -356,6 +358,7 @@ router.post(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if there's an alpha invitation for this email
|
// Check if there's an alpha invitation for this email
|
||||||
|
if (process.env.ALPHA_TESTING_ENABLED === 'true') {
|
||||||
const alphaInvitation = await AlphaInvitation.findOne({
|
const alphaInvitation = await AlphaInvitation.findOne({
|
||||||
where: { email: email.toLowerCase().trim() },
|
where: { email: email.toLowerCase().trim() },
|
||||||
});
|
});
|
||||||
@@ -369,6 +372,7 @@ router.post(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generate JWT tokens
|
// Generate JWT tokens
|
||||||
const token = jwt.sign(
|
const token = jwt.sign(
|
||||||
|
|||||||
@@ -38,6 +38,13 @@ const AppContent: React.FC = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const checkAlphaAccess = async () => {
|
const checkAlphaAccess = async () => {
|
||||||
|
// Bypass alpha access check if feature is disabled
|
||||||
|
if (process.env.REACT_APP_ALPHA_TESTING_ENABLED !== 'true') {
|
||||||
|
setHasAlphaAccess(true);
|
||||||
|
setCheckingAccess(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`${API_URL}/alpha/verify-session`, {
|
const response = await axios.get(`${API_URL}/alpha/verify-session`, {
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user