generated from alphane/template
Initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { CreationAttributes } from "@sequelize/core"
|
||||
import { isNil } from "lodash"
|
||||
|
||||
import logger from "@/utils/logger"
|
||||
import { CreateService } from "@/services/users"
|
||||
import { User } from "@/models"
|
||||
|
||||
export async function seed(): Promise<void> {
|
||||
const systemUserAttributes: CreationAttributes<User> = {
|
||||
email: "system.user@alphane.com",
|
||||
auth0Subject: "NO_LOGIN_system.user@alphane.com",
|
||||
firstName: "System",
|
||||
lastName: "User",
|
||||
displayName: "System User",
|
||||
roles: [User.Roles.SYSTEM_ADMIN],
|
||||
}
|
||||
|
||||
const user = await User.findOne({
|
||||
where: {
|
||||
email: systemUserAttributes.email,
|
||||
},
|
||||
})
|
||||
|
||||
if (isNil(user)) {
|
||||
const createdUser = await CreateService.perform(systemUserAttributes)
|
||||
logger.debug("System User created:", createdUser.dataValues)
|
||||
} else {
|
||||
await user.update(systemUserAttributes)
|
||||
logger.debug("System User updated:", user.dataValues)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user