Skip to content

Commit

Permalink
reject requests with invalid email format
Browse files Browse the repository at this point in the history
  • Loading branch information
abichan99911111 committed Sep 27, 2024
1 parent e5c1fa2 commit 55dff1c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/app/src/server/routes/apiv3/forgot-password.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ module.exports = (crowi) => {
}

router.post('/', checkPassportStrategyMiddleware, addActivity, async(req, res) => {
const validEmailRegexp = new RegExp(/^[\w+\-.]+@[a-z\d\-.]+\.[a-z]+$/, 'i');
const { email } = req.body;
const locale = configManager.getConfig('crowi', 'app:globalLang');
const appUrl = appService.getSiteUrl();

try {
if (!validEmailRegexp.test(email.toString())) {
throw new Error('invalid email format.');
}

const user = await User.findOne({ email });

// when the user is not found or active
Expand Down

0 comments on commit 55dff1c

Please sign in to comment.