fix: setup to allow login to Medusa Cloud
This commit is contained in:
@@ -9,7 +9,7 @@ import cwdResolve from "resolve-cwd"
|
||||
import loaders from "../loaders"
|
||||
import Logger from "../loaders/logger"
|
||||
|
||||
export default async function({ directory, email, password }) {
|
||||
export default async function({ directory, id, email, password }) {
|
||||
const app = express()
|
||||
const { container, dbConnection } = await loaders({
|
||||
directory,
|
||||
@@ -17,7 +17,7 @@ export default async function({ directory, email, password }) {
|
||||
})
|
||||
|
||||
const userService = container.resolve("userService")
|
||||
const user = await userService.create({ email }, password)
|
||||
const user = await userService.create({ id, email }, password)
|
||||
|
||||
process.exit()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||
|
||||
export class nullablePassword1619108646647 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "user" ALTER COLUMN "password_hash" DROP NOT NULL`
|
||||
)
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "user" ALTER COLUMN "password_hash" TYPE character varying, ALTER COLUMN "password_hash" NOT NULL`
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ export class User {
|
||||
@Column({ nullable: true })
|
||||
last_name: string
|
||||
|
||||
@Column()
|
||||
@Column({ nullable: true })
|
||||
password_hash: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
|
||||
@@ -153,9 +153,12 @@ class UserService extends BaseService {
|
||||
const userRepo = manager.getCustomRepository(this.userRepository_)
|
||||
|
||||
const validatedEmail = this.validateEmail_(user.email)
|
||||
const hashedPassword = await this.hashPassword_(password)
|
||||
if (password) {
|
||||
const hashedPassword = await this.hashPassword_(password)
|
||||
user.password_hash = hashedPassword
|
||||
}
|
||||
|
||||
user.email = validatedEmail
|
||||
user.password_hash = hashedPassword
|
||||
|
||||
const created = await userRepo.create(user)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user