mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
adjusted seed
This commit is contained in:
parent
22b873c22d
commit
d7f06dad12
@ -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
|
||||
})
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user