Password encryption
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { Table, Column, Model, HasMany, Unique, BelongsTo, ForeignKey } from 'sequelize-typescript';
|
||||
import { Table, Column, Model, HasMany, Unique, BelongsTo, ForeignKey, BeforeCreate, BeforeUpdate } from 'sequelize-typescript';
|
||||
import { Order } from '../ordering/order.model';
|
||||
import { Address } from './address.model';
|
||||
import { Payment } from './payment.model';
|
||||
import { AccountRole } from './accountRole.model';
|
||||
import { Rating } from '../acts/rating.model';
|
||||
import { encryptString } from '../../scripts/encryptScripts';
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class Account extends Model {
|
||||
@@ -44,4 +45,12 @@ export class Account extends Model {
|
||||
|
||||
@BelongsTo(() => AccountRole)
|
||||
accountRole: AccountRole
|
||||
|
||||
|
||||
// Hooks
|
||||
|
||||
@BeforeCreate
|
||||
static async encryptPassword(instance: Account) {
|
||||
instance.dataValues.password = encryptString(instance.dataValues.password)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user