* chore: Clean up authentication middlewares * chore: Rename AuthUser to AuthIdentity * feat: Define link between user, customer, and auth identity * feat: Use links for auth, update auth context content * fix: Adjust user create command with new auth setup * fix: Make auth login more dynamic, review fixes * fix: Change test assertions for created by
32 lines
830 B
TypeScript
32 lines
830 B
TypeScript
import { AuthIdentity } from "@models"
|
|
import { MapToConfig } from "@medusajs/utils"
|
|
import { ModuleJoinerConfig } from "@medusajs/types"
|
|
import { Modules } from "@medusajs/modules-sdk"
|
|
|
|
export const LinkableKeys = {
|
|
auth_identity_id: AuthIdentity.name,
|
|
}
|
|
|
|
const entityLinkableKeysMap: MapToConfig = {}
|
|
Object.entries(LinkableKeys).forEach(([key, value]) => {
|
|
entityLinkableKeysMap[value] ??= []
|
|
entityLinkableKeysMap[value].push({
|
|
mapTo: key,
|
|
valueFrom: key.split("_").pop()!,
|
|
})
|
|
})
|
|
|
|
export const entityNameToLinkableKeysMap: MapToConfig = entityLinkableKeysMap
|
|
|
|
export const joinerConfig: ModuleJoinerConfig = {
|
|
serviceName: Modules.AUTH,
|
|
primaryKeys: ["id"],
|
|
linkableKeys: LinkableKeys,
|
|
alias: {
|
|
name: ["auth_identity", "auth_identities"],
|
|
args: {
|
|
entity: AuthIdentity.name,
|
|
},
|
|
},
|
|
}
|