mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2025-10-04 02:09:24 +02:00
Sanitize mail addresses
This commit is contained in:
parent
df2cdab180
commit
196afe8ed1
4 changed files with 32 additions and 3 deletions
|
@ -20,7 +20,7 @@ import { Router } from 'express'
|
|||
import { BadRequest } from 'http-errors'
|
||||
import { Database } from '../database'
|
||||
import { sendLoginCode, signInByMailCode } from '../function/authentication/login-by-mail'
|
||||
import { isMailServerBlacklisted } from '../util/mail'
|
||||
import { isMailServerBlacklisted, sanitizeMailAddress } from '../util/mail'
|
||||
import {
|
||||
isSendMailLoginCodeRequest,
|
||||
isSignInByMailCodeRequest
|
||||
|
@ -35,11 +35,17 @@ export const createAuthRouter = (database: Database) => {
|
|||
throw new BadRequest()
|
||||
}
|
||||
|
||||
if (isMailServerBlacklisted(req.body.mail)) {
|
||||
const mail = sanitizeMailAddress(req.body.mail)
|
||||
|
||||
if (!mail) {
|
||||
throw new BadRequest()
|
||||
}
|
||||
|
||||
if (isMailServerBlacklisted(mail)) {
|
||||
res.json({ mailServerBlacklisted: true })
|
||||
} else {
|
||||
const { mailLoginToken } = await sendLoginCode({
|
||||
mail: req.body.mail,
|
||||
mail,
|
||||
locale: req.body.locale,
|
||||
database
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue