Skip to content

Commit 515051d

Browse files
committed
fix: continue work on blocked_email_domains
1 parent c22a69f commit 515051d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/backend/src/routers/save_account.js

+12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const auth = require('../middleware/auth.js');
2424
const config = require('../config');
2525
const { Context } = require('../util/context');
2626
const { DB_WRITE } = require('../services/database/consts');
27+
const { can } = require('../util/langutil.js');
2728

2829
// -----------------------------------------------------------------------//
2930
// POST /save_account
@@ -70,6 +71,17 @@ router.post('/save_account', auth, express.json(), async (req, res, next)=>{
7071
else if(req.body.password.length < config.min_pass_length)
7172
return res.status(400).send(`Password must be at least ${config.min_pass_length} characters long.`)
7273

74+
const svc_cleanEmail = req.services.get('clean-email')
75+
const clean_email = svc_cleanEmail.clean(req.body.email);
76+
77+
if ( can(config.blocked_email_domains, 'iterate') ) {
78+
for ( const suffix of config.blocked_email_domains ) {
79+
if ( clean_email.endsWith(suffix) ) {
80+
return res.status(400).send('This email domain is not allowed.');
81+
}
82+
}
83+
}
84+
7385
const svc_edgeRateLimit = req.services.get('edge-rate-limit');
7486
if ( ! svc_edgeRateLimit.check('save-account') ) {
7587
return res.status(429).send('Too many requests.');

0 commit comments

Comments
 (0)