mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Add UA_MAIL_BLOCKLIST option
This commit is contained in:
+4
-1
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user