juice-shop
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 */
7import {8Model,9type InferAttributes,10type InferCreationAttributes,11DataTypes,12type CreationOptional,13type Sequelize14} from 'sequelize'15import * as security from '../lib/insecurity'16
17class SecurityAnswer extends Model<18InferAttributes<SecurityAnswer>,19InferCreationAttributes<SecurityAnswer>20> {21declare SecurityQuestionId: number22declare UserId: number23declare id: CreationOptional<number>24declare answer: string25}
26
27const SecurityAnswerModelInit = (sequelize: Sequelize) => {28SecurityAnswer.init(29{30UserId: {31type: DataTypes.INTEGER,32unique: true33},34SecurityQuestionId: {35type: DataTypes.INTEGER36},37
38id: {39type: DataTypes.INTEGER,40primaryKey: true,41autoIncrement: true42},43answer: {44type: DataTypes.STRING,45set (answer: string) {46this.setDataValue('answer', security.hmac(answer))47}48}49},50{51tableName: 'SecurityAnswers',52sequelize
53}54)55}
56
57export { SecurityAnswer as SecurityAnswerModel, SecurityAnswerModelInit }58