Add UA_MAIL_BLOCKLIST option

This commit is contained in:
Jonas Lochmann
2024-03-18 01:00:00 +01:00
parent 120ea33547
commit e6cc08a292
3 changed files with 15 additions and 4 deletions
+4 -1
View File
@@ -17,7 +17,8 @@
import { json } from 'body-parser'
import { Router } from 'express'
import { BadRequest } from 'http-errors'
import { BadRequest, Forbidden } from 'http-errors'
import { config } from '../config'
import { Database } from '../database'
import { sendLoginCode, signInByMailCode } from '../function/authentication/login-by-mail'
import { isMailAddressCoveredByWhitelist, isMailServerBlacklisted, sanitizeMailAddress } from '../util/mail'
@@ -49,6 +50,8 @@ export const createAuthRouter = (database: Database) => {
res.json({ mailAddressNotWhitelisted: true })
} else if (isMailServerBlacklisted(mail)) {
res.json({ mailServerBlacklisted: true })
} else if (config.uaMailBlocklist.indexOf(req.headers['user-agent'] || '') !== -1) {
throw new Forbidden()
} else {
const { mailLoginToken } = await sendLoginCode({
mail,