File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 1- import { AuthService } from '@/services/auth.service'
1+ import { UserService } from '@/services/users.service'
2+ import * as bcrypt from 'bcrypt'
23import Container from 'typedi'
34import { db } from './db'
45import { channelTypes } from './schema'
@@ -22,13 +23,16 @@ async function seedChannelTypes() {
2223
2324async function seedDefaultAccount ( ) {
2425 try {
25- const authService = Container . get ( AuthService )
26+ const userService = Container . get ( UserService )
2627
27- await authService . register ( {
28+ const hashedPassword = await bcrypt . hash ( 'admin' , 10 )
29+
30+ await userService . create ( {
28312932 name : 'Admin' ,
30- password : 'admin' ,
31- passwordConfirm : 'admin' ,
33+ isVerified : true ,
34+ password : hashedPassword ,
35+ roles : [ 'ADMIN' , 'USER' ] ,
3236 } )
3337
3438 console . log ( 'Default account created' )
Original file line number Diff line number Diff line change @@ -39,7 +39,15 @@ export class UserService {
3939 }
4040
4141 public async create ( fields : TNewUser ) {
42- const [ user ] = await db . insert ( users ) . values ( fields ) . returning ( )
42+ const [ user ] = await db
43+ . insert ( users )
44+ . values ( {
45+ ...fields ,
46+ avatar : `https://ui-avatars.com/api/?background=random&name=${
47+ fields . name || fields . email || 'User'
48+ } `,
49+ } )
50+ . returning ( )
4351
4452 await this . channelService . createDefaultChannel ( user . id )
4553
You can’t perform that action at this time.
0 commit comments