feat: Revert to using app_metadata for authentication (#7433)

This commit is contained in:
Stevche Radevski
2024-05-23 22:01:41 +02:00
committed by GitHub
parent 6ec6e2c7b6
commit 135772b27b
24 changed files with 149 additions and 265 deletions
@@ -2,7 +2,6 @@ import { CreateCustomerDTO, MedusaContainer } from "@medusajs/types"
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
import jwt from "jsonwebtoken"
import { ContainerRegistrationKeys } from "@medusajs/utils"
export const createAuthenticatedCustomer = async (
appContainer: MedusaContainer,
@@ -13,7 +12,6 @@ export const createAuthenticatedCustomer = async (
const customerModuleService = appContainer.resolve(
ModuleRegistrationName.CUSTOMER
)
const remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK)
const customer = await customerModuleService.create({
first_name: "John",
@@ -25,19 +23,10 @@ export const createAuthenticatedCustomer = async (
const authIdentity = await authService.create({
entity_id: "store_user",
provider: "emailpass",
})
// Ideally we simulate a signup process than manually linking here.
await remoteLink.create([
{
[Modules.CUSTOMER]: {
customer_id: customer.id,
},
[Modules.AUTH]: {
auth_identity_id: authIdentity.id,
},
app_metadata: {
customer_id: customer.id,
},
])
})
const token = jwt.sign(
{