juice-shop

Форк
0
/
securityQuestion.ts 
33 строки · 1.0 Кб
1
/*
2
 * Copyright (c) 2014-2024 Bjoern Kimminich & the OWASP Juice Shop contributors.
3
 * SPDX-License-Identifier: MIT
4
 */
5

6
import { type Request, type Response, type NextFunction } from 'express'
7
import { SecurityAnswerModel } from '../models/securityAnswer'
8
import { UserModel } from '../models/user'
9
import { SecurityQuestionModel } from '../models/securityQuestion'
10

11
module.exports = function securityQuestion () {
12
  return ({ query }: Request, res: Response, next: NextFunction) => {
13
    const email = query.email
14
    SecurityAnswerModel.findOne({
15
      include: [{
16
        model: UserModel,
17
        where: { email: email?.toString() }
18
      }]
19
    }).then((answer: SecurityAnswerModel | null) => {
20
      if (answer != null) {
21
        SecurityQuestionModel.findByPk(answer.SecurityQuestionId).then((question: SecurityQuestionModel | null) => {
22
          res.json({ question })
23
        }).catch((error: Error) => {
24
          next(error)
25
        })
26
      } else {
27
        res.json({})
28
      }
29
    }).catch((error: unknown) => {
30
      next(error)
31
    })
32
  }
33
}
34

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.