juice-shop

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

6
/* jslint node: true */
7
import {
8
  Model,
9
  type InferAttributes,
10
  type InferCreationAttributes,
11
  DataTypes,
12
  type CreationOptional,
13
  type Sequelize
14
} from 'sequelize'
15
import * as security from '../lib/insecurity'
16

17
class SecurityAnswer extends Model<
18
InferAttributes<SecurityAnswer>,
19
InferCreationAttributes<SecurityAnswer>
20
> {
21
  declare SecurityQuestionId: number
22
  declare UserId: number
23
  declare id: CreationOptional<number>
24
  declare answer: string
25
}
26

27
const SecurityAnswerModelInit = (sequelize: Sequelize) => {
28
  SecurityAnswer.init(
29
    {
30
      UserId: {
31
        type: DataTypes.INTEGER,
32
        unique: true
33
      },
34
      SecurityQuestionId: {
35
        type: DataTypes.INTEGER
36
      },
37

38
      id: {
39
        type: DataTypes.INTEGER,
40
        primaryKey: true,
41
        autoIncrement: true
42
      },
43
      answer: {
44
        type: DataTypes.STRING,
45
        set (answer: string) {
46
          this.setDataValue('answer', security.hmac(answer))
47
        }
48
      }
49
    },
50
    {
51
      tableName: 'SecurityAnswers',
52
      sequelize
53
    }
54
  )
55
}
56

57
export { SecurityAnswer as SecurityAnswerModel, SecurityAnswerModelInit }
58

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

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

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

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