-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Turn off waitlist feature using a feature flag.
- Loading branch information
Showing
5 changed files
with
42 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { | |
ASSET_FOLDER, | ||
CLIENT_URL, | ||
EMAIL_VERIFICATION_JWT, | ||
FEATURE_FLAGS, | ||
} from '../config/keys'; | ||
import { NextFunction, Request, Response } from 'express'; | ||
import { Document, Types } from 'mongoose'; | ||
|
@@ -195,20 +196,28 @@ const jwtSignup = async (req: Request, res: Response) => { | |
const { email, password, first_name, last_name, mentor, inviteCode } = | ||
req.body; | ||
|
||
if (!mentor) { | ||
const invite = await Waitlist.findOne({ inviteCode }); | ||
if (FEATURE_FLAGS.waitlist) { | ||
if (!mentor) { | ||
const invite = await Waitlist.findOne({ inviteCode }); | ||
|
||
if (!invite || (invite.email !== email && invite.email !== '*')) { | ||
return res.status(401).json({ | ||
error: 'Invalid or used invite code', | ||
}); | ||
} | ||
if (!invite || (invite.email !== email && invite.email !== '*')) { | ||
return res.status(401).json({ | ||
error: 'Invalid or used invite code', | ||
}); | ||
} | ||
|
||
if (invite.email === email) { | ||
await invite.remove(); | ||
if (invite.email === email) { | ||
await invite.remove(); | ||
} | ||
} | ||
} | ||
|
||
if (!/^[A-Za-z0-9._%+-][email protected]$/i.test(email)) { | ||
return res.status(400).json({ | ||
error: 'You must use a Thapar email address', | ||
}); | ||
} | ||
|
||
const user = new UserModel({ | ||
email, | ||
password, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters