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.passphraseShown = context.passphraseShown ? context.passphraseShown : false
|
||||||
user.language = context.language ? context.language : 'en'
|
user.language = context.language ? context.language : 'en'
|
||||||
user.publisherId = context.publisherId ? context.publisherId : 0
|
user.publisherId = context.publisherId ? context.publisherId : 0
|
||||||
|
user.passphrase = context.passphrase ? context.passphrase : faker.random.words(24)
|
||||||
|
|
||||||
return user
|
return user
|
||||||
})
|
})
|
||||||
|
|||||||
@ -15,12 +15,7 @@ export interface UserContext {
|
|||||||
passphraseShown?: boolean
|
passphraseShown?: boolean
|
||||||
language?: string
|
language?: string
|
||||||
publisherId?: number
|
publisherId?: number
|
||||||
}
|
|
||||||
|
|
||||||
export interface LoginUserBackupContext {
|
|
||||||
userId?: number
|
|
||||||
passphrase?: string
|
passphrase?: string
|
||||||
mnemonicType?: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ServerUserContext {
|
export interface ServerUserContext {
|
||||||
@ -33,8 +28,3 @@ export interface ServerUserContext {
|
|||||||
created?: Date
|
created?: Date
|
||||||
modified?: Date
|
modified?: Date
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LoginUserRolesContext {
|
|
||||||
userId?: number
|
|
||||||
roleId?: number
|
|
||||||
}
|
|
||||||
|
|||||||
@ -17,9 +17,7 @@ export interface UserInterface {
|
|||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
groupId?: number
|
groupId?: number
|
||||||
publisherId?: number
|
publisherId?: number
|
||||||
// from login user backup
|
|
||||||
passphrase?: string
|
passphrase?: string
|
||||||
mnemonicType?: number
|
|
||||||
// from server user
|
// from server user
|
||||||
serverUserPassword?: string
|
serverUserPassword?: string
|
||||||
role?: string
|
role?: string
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { UserContext, LoginUserBackupContext, ServerUserContext } from '../../interface/UserContext'
|
import { UserContext, ServerUserContext } from '../../interface/UserContext'
|
||||||
import {
|
import {
|
||||||
BalanceContext,
|
BalanceContext,
|
||||||
TransactionContext,
|
TransactionContext,
|
||||||
@ -7,7 +7,6 @@ import {
|
|||||||
} from '../../interface/TransactionContext'
|
} from '../../interface/TransactionContext'
|
||||||
import { UserInterface } from '../../interface/UserInterface'
|
import { UserInterface } from '../../interface/UserInterface'
|
||||||
import { User } from '../../../entity/User'
|
import { User } from '../../../entity/User'
|
||||||
import { LoginUserBackup } from '../../../entity/LoginUserBackup'
|
|
||||||
import { ServerUser } from '../../../entity/ServerUser'
|
import { ServerUser } from '../../../entity/ServerUser'
|
||||||
import { Balance } from '../../../entity/Balance'
|
import { Balance } from '../../../entity/Balance'
|
||||||
import { Transaction } from '../../../entity/Transaction'
|
import { Transaction } from '../../../entity/Transaction'
|
||||||
@ -17,9 +16,6 @@ import { Factory } from 'typeorm-seeding'
|
|||||||
|
|
||||||
export const userSeeder = async (factory: Factory, userData: UserInterface): Promise<void> => {
|
export const userSeeder = async (factory: Factory, userData: UserInterface): Promise<void> => {
|
||||||
const user = await factory(User)(createUserContext(userData)).create()
|
const user = await factory(User)(createUserContext(userData)).create()
|
||||||
await factory(LoginUserBackup)(
|
|
||||||
createLoginUserBackupContext(userData, (<User>user).loginUserId),
|
|
||||||
).create()
|
|
||||||
|
|
||||||
if (userData.isAdmin) {
|
if (userData.isAdmin) {
|
||||||
await factory(ServerUser)(createServerUserContext(userData)).create()
|
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 => {
|
const createServerUserContext = (context: UserInterface): ServerUserContext => {
|
||||||
return {
|
return {
|
||||||
role: context.role,
|
role: context.role,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user