mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2025-10-03 17:59:24 +02:00
Add option to specify mail providers which are not supported
This commit is contained in:
parent
a7533b7864
commit
5987583ca3
3 changed files with 34 additions and 0 deletions
|
@ -24,6 +24,7 @@ import {
|
|||
isSendMailLoginCodeRequest,
|
||||
isSignInByMailCodeRequest
|
||||
} from './validator'
|
||||
import { isMailServerBlacklisted } from '../util/mail'
|
||||
|
||||
export const createAuthRouter = (database: Database) => {
|
||||
const router = Router()
|
||||
|
@ -46,6 +47,28 @@ export const createAuthRouter = (database: Database) => {
|
|||
}
|
||||
})
|
||||
|
||||
router.post('/send-mail-login-code-v2', json(), async (req, res, next) => {
|
||||
try {
|
||||
if (!isSendMailLoginCodeRequest(req.body)) {
|
||||
throw new BadRequest()
|
||||
}
|
||||
|
||||
if (isMailServerBlacklisted(req.body.mail)) {
|
||||
res.json({ mailServerBlacklisted: true })
|
||||
} else {
|
||||
const { mailLoginToken } = await sendLoginCode({
|
||||
mail: req.body.mail,
|
||||
locale: req.body.locale,
|
||||
database
|
||||
})
|
||||
|
||||
res.json({ mailLoginToken })
|
||||
}
|
||||
} catch (ex) {
|
||||
next(ex)
|
||||
}
|
||||
})
|
||||
|
||||
router.post('/sign-in-by-mail-code', json(), async (req, res, next) => {
|
||||
try {
|
||||
if (!isSignInByMailCodeRequest(req.body)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue