You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
3.3 KiB
TypeScript
166 lines
3.3 KiB
TypeScript
import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
|
|
import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm";
|
|
import * as bcrypt from 'bcrypt';
|
|
import { BadRequestException } from "@nestjs/common";
|
|
|
|
@Entity('pcduser')
|
|
export class Pcduser extends PcdBaseEntity {
|
|
@PrimaryColumn({
|
|
name: "user_id",
|
|
primary: true,
|
|
type: "varchar",
|
|
length: 12
|
|
})
|
|
userId: string;
|
|
@Column({
|
|
name: "user_name",
|
|
type: "varchar",
|
|
length: 100
|
|
})
|
|
userName: string;
|
|
|
|
@Column({
|
|
name: "group_or_user",
|
|
type: "char",
|
|
length: 1,
|
|
default: () => "'U'",
|
|
})
|
|
groupOrUser: string;
|
|
@Column({
|
|
name: "pass",
|
|
type: "varchar",
|
|
length: 500
|
|
})
|
|
pass: string | null;
|
|
|
|
|
|
@Column({
|
|
name: "salt",
|
|
type: "varchar",
|
|
nullable: true,
|
|
length: 50
|
|
})
|
|
salt: string | null;
|
|
|
|
|
|
@Column({
|
|
name: "secu_level",
|
|
type: "char",
|
|
nullable: true,
|
|
length: 1
|
|
})
|
|
secuLevel: string | null;
|
|
|
|
@Column({
|
|
name: "pwd_exp_days",
|
|
type: "int",
|
|
nullable: true,
|
|
default: () => "(0)"
|
|
})
|
|
pwdExpDays: number | null;
|
|
|
|
@Column({
|
|
name: 'email',
|
|
type: 'varchar',
|
|
length: 500,
|
|
// unique: true,
|
|
nullable: true
|
|
})
|
|
email: string;
|
|
|
|
@Column({
|
|
name: 'mobile_number',
|
|
type: 'varchar',
|
|
length: 100,
|
|
nullable: true,
|
|
unique: false
|
|
})
|
|
mobileNumber: string;
|
|
|
|
@Column({
|
|
name: 'refresh_token',
|
|
type: 'varchar',
|
|
nullable: true,
|
|
length: 100,
|
|
})
|
|
refreshtoken: string;
|
|
|
|
@Column({
|
|
name: 'user_image_path',
|
|
type: 'varchar',
|
|
length: 500,
|
|
nullable: true
|
|
})
|
|
userImagePath: string;
|
|
|
|
@Column({
|
|
name: 'member_no',
|
|
type: 'varchar',
|
|
length: 20,
|
|
nullable: true
|
|
})
|
|
memberNo: string;
|
|
|
|
@Column({
|
|
type: 'varchar',
|
|
name: "cust_id",
|
|
nullable: true,
|
|
length: 20,
|
|
})
|
|
custId: string;
|
|
|
|
@Column({
|
|
name: "device_id",
|
|
type: "varchar"
|
|
})
|
|
deviceId:string;
|
|
|
|
|
|
@Column({
|
|
type: 'char',
|
|
name: "status",
|
|
nullable: true,
|
|
length: 1
|
|
})
|
|
status: string;
|
|
@Column({
|
|
type: 'varchar',
|
|
name: "bank_id",
|
|
nullable: true,
|
|
unique: true,
|
|
length: 20,
|
|
})
|
|
bankId: string;
|
|
@Column({
|
|
name: "t_pass",
|
|
type: "varchar",
|
|
length: 500
|
|
})
|
|
tPass: string | null;
|
|
|
|
|
|
@Column({
|
|
name: "t_salt",
|
|
type: "varchar",
|
|
nullable: true,
|
|
length: 50
|
|
})
|
|
tSalt: string | null;
|
|
async validatePassword(password: string,user ): Promise<boolean> {
|
|
if((user.deviceId==='null' || user.deviceId==="" || user.deviceId === undefined) && (user.bankId !='acc1' && user.bankId != 'sims')){
|
|
throw new BadRequestException("Device not Registered.Please Register");
|
|
}else{
|
|
const hash = await bcrypt.hash(password, this.salt);
|
|
return hash === this.pass;
|
|
|
|
}
|
|
}
|
|
|
|
async validateTransactionPassword(password: string): Promise<boolean> {
|
|
const hash = await bcrypt.hash(password, this.tSalt);
|
|
return hash === this.tPass;
|
|
|
|
}
|
|
|
|
|
|
} |