* 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
63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
import { Modules } from "@medusajs/modules-sdk"
|
|
import { ModuleJoinerConfig } from "@medusajs/types"
|
|
import { LINKS } from "@medusajs/utils"
|
|
|
|
export const CustomerAuth: ModuleJoinerConfig = {
|
|
serviceName: LINKS.CustomerAuth,
|
|
isLink: true,
|
|
databaseConfig: {
|
|
tableName: "customer_auth_identity",
|
|
idPrefix: "cusauth",
|
|
},
|
|
alias: [
|
|
{
|
|
name: "customer_auth_identity",
|
|
},
|
|
{
|
|
name: "customer_auth_identities",
|
|
},
|
|
],
|
|
primaryKeys: ["id", "customer_id", "auth_identity_id"],
|
|
relationships: [
|
|
{
|
|
serviceName: Modules.CUSTOMER,
|
|
primaryKey: "id",
|
|
foreignKey: "customer_id",
|
|
alias: "customer",
|
|
},
|
|
{
|
|
serviceName: Modules.AUTH,
|
|
isInternalService: true,
|
|
primaryKey: "id",
|
|
foreignKey: "auth_identity_id",
|
|
alias: "auth",
|
|
},
|
|
],
|
|
extends: [
|
|
{
|
|
serviceName: Modules.CUSTOMER,
|
|
fieldAlias: {
|
|
auth_identity: "auth_link.auth_identity",
|
|
},
|
|
relationship: {
|
|
serviceName: LINKS.CustomerAuth,
|
|
primaryKey: "customer_id",
|
|
foreignKey: "id",
|
|
alias: "auth_link",
|
|
},
|
|
},
|
|
{
|
|
serviceName: Modules.AUTH,
|
|
fieldAlias: {
|
|
customer: "customer_link.customer",
|
|
},
|
|
relationship: {
|
|
serviceName: LINKS.CustomerAuth,
|
|
primaryKey: "auth_identity_id",
|
|
foreignKey: "id",
|
|
alias: "customer_link",
|
|
},
|
|
},
|
|
],
|
|
}
|