summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorJoseph Ditton <jditton.atomic@gmail.com>2021-12-03 18:31:24 -0700
committerJoseph Ditton <jditton.atomic@gmail.com>2021-12-03 18:31:24 -0700
commit5446509b96d5d5bcd0aa9855ce5b9568fe706eb7 (patch)
treedc9c47ceecaa4b0d80756601c91ae0352808bb28 /server
parentedbbed205031fa21c42e309cbf1161e20135e44b (diff)
downloadlocchat-5446509b96d5d5bcd0aa9855ce5b9568fe706eb7.tar.gz
locchat-5446509b96d5d5bcd0aa9855ce5b9568fe706eb7.zip
update readme add git scripts
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;