adjusted seed

This commit is contained in:
Ulf Gebhardt 2022-02-03 20:15:49 +01:00
parent 22b873c22d
commit d7f06dad12
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
4 changed files with 2 additions and 28 deletions

View File

@ -26,6 +26,7 @@ define(User, (faker: typeof Faker, context?: UserContext) => {
user.passphraseShown = context.passphraseShown ? context.passphraseShown : false
user.language = context.language ? context.language : 'en'
user.publisherId = context.publisherId ? context.publisherId : 0
user.passphrase = context.passphrase ? context.passphrase : faker.random.words(24)
return user
})

View File

@ -15,12 +15,7 @@ export interface UserContext {
passphraseShown?: boolean
language?: string
publisherId?: number
}
export interface LoginUserBackupContext {
userId?: number
passphrase?: string
mnemonicType?: number
}
export interface ServerUserContext {
@ -33,8 +28,3 @@ export interface ServerUserContext {
created?: Date
modified?: Date
}
export interface LoginUserRolesContext {
userId?: number
roleId?: number
}

View File

@ -17,9 +17,7 @@ export interface UserInterface {
disabled?: boolean
groupId?: number
publisherId?: number
// from login user backup
passphrase?: string
mnemonicType?: number
// from server user
serverUserPassword?: string
role?: string

View File

@ -1,4 +1,4 @@
import { UserContext, LoginUserBackupContext, ServerUserContext } from '../../interface/UserContext'
import { UserContext, ServerUserContext } from '../../interface/UserContext'
import {
BalanceContext,
TransactionContext,
@ -7,7 +7,6 @@ import {
} from '../../interface/TransactionContext'
import { UserInterface } from '../../interface/UserInterface'
import { User } from '../../../entity/User'
import { LoginUserBackup } from '../../../entity/LoginUserBackup'
import { ServerUser } from '../../../entity/ServerUser'
import { Balance } from '../../../entity/Balance'
import { Transaction } from '../../../entity/Transaction'
@ -17,9 +16,6 @@ import { Factory } from 'typeorm-seeding'
export const userSeeder = async (factory: Factory, userData: UserInterface): Promise<void> => {
const user = await factory(User)(createUserContext(userData)).create()
await factory(LoginUserBackup)(
createLoginUserBackupContext(userData, (<User>user).loginUserId),
).create()
if (userData.isAdmin) {
await factory(ServerUser)(createServerUserContext(userData)).create()
@ -61,17 +57,6 @@ const createUserContext = (context: UserInterface): UserContext => {
}
}
const createLoginUserBackupContext = (
context: UserInterface,
loginUserId: number,
): LoginUserBackupContext => {
return {
passphrase: context.passphrase,
mnemonicType: context.mnemonicType,
userId: loginUserId,
}
}
const createServerUserContext = (context: UserInterface): ServerUserContext => {
return {
role: context.role,