Skip to content

Commit

Permalink
Fix backend e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
glutengo committed Jun 2, 2021
1 parent f997cde commit 59bef07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions generators/server/templates/server/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
<%_ } _%>
"@nestjs/swagger": "3.1.0",
"@nestjs/typeorm": "7.1.4",
<%_ if (authenticationType === 'jwt') { _%>
"bcrypt": "5.0.1",
<%_ } _%>
"class-transformer": "0.3.1",
"class-validator": "0.13.1",
"cloud-config-client": "1.4.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Authority } from './authority.entity';
import { Entity, Column, BeforeInsert, BeforeUpdate <%_ if (databaseType !== 'mongodb') { _%>, ManyToMany, JoinTable <%_ } _%> } from 'typeorm';
import { Entity, Column<%_ if (authenticationType === 'jwt') { _%>, BeforeInsert, BeforeUpdate<%_ } _%> <%_ if (databaseType !== 'mongodb') { _%>, ManyToMany, JoinTable <%_ } _%> } from 'typeorm';
import { BaseEntity } from './base/base.entity';
<%_ if (authenticationType === 'jwt') { _%>
import * as bcrypt from 'bcrypt';
import { config } from '../config';
<% } %>

@Entity('nhi_user')
export class User extends BaseEntity {
Expand Down Expand Up @@ -42,11 +44,13 @@ export class User extends BaseEntity {
@Column({ nullable: true })
resetDate?: Date;

<%_ if (authenticationType === 'jwt') { _%>
@BeforeInsert()
@BeforeUpdate()
async hashPassword?(): Promise<void> {
if (this.password) {
this.password = await bcrypt.hash(this.password, config.get('jhipster.security.authentication.jwt.hash-salt-or-rounds'));
}
}
<%_ } _%>
}

0 comments on commit 59bef07

Please sign in to comment.