committed by
GitHub
parent
c661cc789b
commit
eb8034502b
@@ -1,7 +1,7 @@
|
||||
import { IsEmail, IsNotEmpty, IsString } from "class-validator"
|
||||
|
||||
import AuthService from "../../../../services/auth"
|
||||
import { EntityManager } from "typeorm";
|
||||
import { EntityManager } from "typeorm"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import _ from "lodash"
|
||||
import jwt from "jsonwebtoken"
|
||||
@@ -78,7 +78,9 @@ import { validator } from "../../../../utils/validator"
|
||||
* $ref: "#/components/responses/500_error"
|
||||
*/
|
||||
export default async (req, res) => {
|
||||
const { projectConfig: { jwt_secret } } = req.scope.resolve('configModule')
|
||||
const {
|
||||
projectConfig: { jwt_secret },
|
||||
} = req.scope.resolve("configModule")
|
||||
if (!jwt_secret) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.NOT_FOUND,
|
||||
@@ -90,10 +92,9 @@ export default async (req, res) => {
|
||||
const authService: AuthService = req.scope.resolve("authService")
|
||||
const manager: EntityManager = req.scope.resolve("manager")
|
||||
const result = await manager.transaction(async (transactionManager) => {
|
||||
return await authService.withTransaction(transactionManager).authenticate(
|
||||
validated.email,
|
||||
validated.password
|
||||
)
|
||||
return await authService
|
||||
.withTransaction(transactionManager)
|
||||
.authenticate(validated.email, validated.password)
|
||||
})
|
||||
|
||||
if (result.success && result.user) {
|
||||
|
||||
Reference in New Issue
Block a user