Skip to content

Commit 528a766

Browse files
committed
fix(dashboard-api): remove flawed onboarding project hijack and enforce email verification
1 parent 2aba36a commit 528a766

2 files changed

Lines changed: 3 additions & 19 deletions

File tree

apps/dashboard-api/src/controllers/project.controller.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,6 @@ module.exports.createProject = async (req, res) => {
269269
const executeOperation = async (session) => {
270270
const { name, description, siteUrl } = createProjectSchema.parse(req.body);
271271

272-
if (!req.user.onboarding?.completed) {
273-
const queryOpts = session ? { session } : {};
274-
const existing = await Project.findOne({ owner: req.user._id }, null, queryOpts);
275-
if (existing) {
276-
const projectObj = existing.toObject();
277-
prepareCreatedProjectResponse(projectObj, req.user);
278-
return { projectObj, newProject: existing };
279-
}
280-
}
281272

282273
if (req.projectLimit !== undefined) {
283274
const queryOpts = session ? { session } : {};
@@ -324,15 +315,6 @@ module.exports.createProject = async (req, res) => {
324315
return { projectObj, newProject };
325316
};
326317

327-
if (!req.user.onboarding?.completed) {
328-
const existing = await Project.findOne({ owner: req.user._id }).lean();
329-
if (existing) {
330-
await markDeveloperOnboardingStep(req.user._id, 'projectCreated', { projectId: existing._id });
331-
const projectObj = { ...existing };
332-
prepareCreatedProjectResponse(projectObj, req.user);
333-
return res.status(201).json(projectObj);
334-
}
335-
}
336318

337319
let session = null;
338320
try {

apps/dashboard-api/src/middlewares/planEnforcement.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ exports.checkProjectLimit = async function(req, res, next) {
3838
const { resolveEffectivePlan, getPlanLimits } = require('@urbackend/common');
3939
try {
4040
if (isAdminRequest(req)) return next();
41-
if (!req.developer?.isVerified) return next();
41+
if (!req.developer?.isVerified) {
42+
return next(new AppError(403, 'Email not verified. Please verify your email to create a project.'));
43+
}
4244

4345
const effectivePlan = resolveEffectivePlan(req.developer);
4446
const limits = getPlanLimits({ plan: effectivePlan });

0 commit comments

Comments
 (0)