Feat(auth): Rename authentication to auth (#6229)
**What** - rename `authenticationModule` -> `authModule`
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import {
|
||||
Entity,
|
||||
Enum,
|
||||
OptionalProps,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
} from "@mikro-orm/core"
|
||||
|
||||
import { ProviderDomain } from "../types/repositories/auth-provider"
|
||||
|
||||
type OptionalFields = "domain" | "is_active" | "config"
|
||||
|
||||
@Entity()
|
||||
export default class AuthProvider {
|
||||
[OptionalProps]: OptionalFields
|
||||
|
||||
@PrimaryKey({ columnType: "text" })
|
||||
provider!: string
|
||||
|
||||
@Property({ columnType: "text" })
|
||||
name: string
|
||||
|
||||
@Enum({ items: () => ProviderDomain, default: ProviderDomain.ALL })
|
||||
domain: ProviderDomain = ProviderDomain.ALL
|
||||
|
||||
@Property({ columnType: "jsonb", nullable: true })
|
||||
config: Record<string, unknown> | null = null
|
||||
|
||||
@Property({ columnType: "boolean", default: false })
|
||||
is_active = false
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import {
|
||||
BeforeCreate,
|
||||
Cascade,
|
||||
Entity,
|
||||
Index,
|
||||
ManyToOne,
|
||||
OnInit,
|
||||
OptionalProps,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
Unique,
|
||||
} from "@mikro-orm/core"
|
||||
|
||||
import AuthProvider from "./auth-provider"
|
||||
import { generateEntityId } from "@medusajs/utils"
|
||||
|
||||
type OptionalFields = "provider_metadata" | "app_metadata" | "user_metadata"
|
||||
|
||||
@Entity()
|
||||
@Unique({ properties: ["provider","entity_id" ], name: "IDX_auth_user_provider_entity_id" })
|
||||
export default class AuthUser {
|
||||
[OptionalProps]: OptionalFields
|
||||
|
||||
@PrimaryKey({ columnType: "text" })
|
||||
id!: string
|
||||
|
||||
@Property({ columnType: "text" })
|
||||
entity_id: string
|
||||
|
||||
@ManyToOne(() => AuthProvider, {
|
||||
joinColumn: "provider",
|
||||
fieldName: "provider_id",
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
provider: AuthProvider
|
||||
|
||||
@Property({ columnType: "jsonb", nullable: true })
|
||||
user_metadata: Record<string, unknown> | null
|
||||
|
||||
@Property({ columnType: "jsonb", nullable: true })
|
||||
app_metadata: Record<string, unknown> | null
|
||||
|
||||
@Property({ columnType: "jsonb", nullable: true })
|
||||
provider_metadata: Record<string, unknown> | null
|
||||
|
||||
@BeforeCreate()
|
||||
onCreate() {
|
||||
this.id = generateEntityId(this.id, "authusr")
|
||||
}
|
||||
|
||||
@OnInit()
|
||||
onInit() {
|
||||
this.id = generateEntityId(this.id, "authusr")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export { default as AuthUser } from "./auth-user"
|
||||
export { default as AuthProvider } from "./auth-provider"
|
||||
Reference in New Issue
Block a user