chore(medusa): Add transactions in mutating actions 2 (#1853)
* chore(medusa): Add transaction on mutation actions * chore(medusa): continue refactoring * chore(medusa): continue refactoring * chore(medusa): continue refactoring * feat(medusa): update invite service mock to provide a withTransaction * feat(medusa): Include pr feedback * feat(medusa): Cleanup idempotent places * feat(medusa): Cleanup idempotent places * feat(medusa): Better Cleanup idempotent places * feat(meudsa): cleanup transaction * fix(medusa): Create cart transaction usage * fix(medusa): Use the right variable * fix(medusa): Use the right variable * fix(medusa): Transaction usage in cart creation flow
This commit is contained in:
@@ -4,6 +4,7 @@ import { validator } from "../../../../utils/validator"
|
||||
import { IsEmail, IsNotEmpty, IsString } from "class-validator"
|
||||
import AuthService from "../../../../services/auth"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { EntityManager } from "typeorm";
|
||||
|
||||
/**
|
||||
* @oas [post] /auth
|
||||
@@ -37,10 +38,13 @@ export default async (req, res) => {
|
||||
const validated = await validator(AdminPostAuthReq, req.body)
|
||||
|
||||
const authService: AuthService = req.scope.resolve("authService")
|
||||
const result = await authService.authenticate(
|
||||
validated.email,
|
||||
validated.password
|
||||
)
|
||||
const manager: EntityManager = req.scope.resolve("manager")
|
||||
const result = await manager.transaction(async (transactionManager) => {
|
||||
return await authService.withTransaction(transactionManager).authenticate(
|
||||
validated.email,
|
||||
validated.password
|
||||
)
|
||||
})
|
||||
|
||||
if (result.success && result.user) {
|
||||
// Add JWT to cookie
|
||||
|
||||
Reference in New Issue
Block a user