summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/users.controller.ts3
-rw-r--r--server/database/migrations/1637028716848-AddUser.ts7
-rw-r--r--server/database/seeds.ts3
-rw-r--r--server/dto/create_user.dto.ts3
-rw-r--r--server/entities/user.entity.ts5
5 files changed, 16 insertions, 5 deletions
diff --git a/server/controllers/users.controller.ts b/server/controllers/users.controller.ts
index fda71b3..b06a8fd 100644
--- a/server/controllers/users.controller.ts
+++ b/server/controllers/users.controller.ts
@@ -43,7 +43,8 @@ export class UsersController {
async create(@Body() userPayload: CreateUserDto, @Res({ passthrough: true }) res: Response) {
const newUser = new User();
newUser.email = userPayload.email;
- newUser.name = userPayload.name;
+ newUser.firstName = userPayload.firstName;
+ newUser.lastName = userPayload.lastName;
newUser.passwordHash = await bcrypt.hash(userPayload.password, 10);
const [role] = await this.rolesService.findByKey(RoleKey.USER);
const userRole = new UserRole();
diff --git a/server/database/migrations/1637028716848-AddUser.ts b/server/database/migrations/1637028716848-AddUser.ts
index 5cc3b7c..13cbbe0 100644
--- a/server/database/migrations/1637028716848-AddUser.ts
+++ b/server/database/migrations/1637028716848-AddUser.ts
@@ -13,7 +13,12 @@ export class AddUser1637028716848 implements MigrationInterface {
isGenerated: true,
},
{
- name: 'name',
+ name: 'firstName',
+ type: 'text',
+ isNullable: false,
+ },
+ {
+ name: 'lastName',
type: 'text',
isNullable: false,
},
diff --git a/server/database/seeds.ts b/server/database/seeds.ts
index 4e9acc4..3b6cdf9 100644
--- a/server/database/seeds.ts
+++ b/server/database/seeds.ts
@@ -36,7 +36,8 @@ export default class Seeds implements Seeder {
adminUser = new User();
adminUser.email = process.env.ADMIN_EMAIL;
adminUser.passwordHash = passwordHash;
- adminUser.name = 'Site Admin';
+ adminUser.firstName = 'Admin';
+ adminUser.lastName = 'Site';
const adminUserRole = new UserRole();
adminUserRole.role = adminRole;
adminUser.userRoles = [adminUserRole];
diff --git a/server/dto/create_user.dto.ts b/server/dto/create_user.dto.ts
index cf87fed..3c84f2c 100644
--- a/server/dto/create_user.dto.ts
+++ b/server/dto/create_user.dto.ts
@@ -1,5 +1,6 @@
export class CreateUserDto {
- name: string;
+ firstName: string;
+ lastName: string;
email: string;
password: string;
}
diff --git a/server/entities/user.entity.ts b/server/entities/user.entity.ts
index 7d0537c..aeef107 100644
--- a/server/entities/user.entity.ts
+++ b/server/entities/user.entity.ts
@@ -11,7 +11,10 @@ export class User {
email: string;
@Column({ nullable: false })
- name: string;
+ firstName: string;
+
+ @Column({ nullable: false })
+ lastName: string;
@Column({ nullable: false })
passwordHash: string;