feat: Flatten the provider config for all modules (#7930)
This commit is contained in:
@@ -9,18 +9,19 @@ import {
|
||||
} from "@types"
|
||||
|
||||
const registrationFn = async (klass, container, pluginOptions) => {
|
||||
Object.entries(pluginOptions.config || []).map(([name, config]) => {
|
||||
container.register({
|
||||
[AuthProviderRegistrationPrefix + name]: asFunction(
|
||||
(cradle) => new klass(cradle, config),
|
||||
{
|
||||
lifetime: klass.LIFE_TIME || Lifetime.SINGLETON,
|
||||
}
|
||||
),
|
||||
})
|
||||
|
||||
container.registerAdd(AuthIdentifiersRegistrationName, asValue(name))
|
||||
container.register({
|
||||
[AuthProviderRegistrationPrefix + pluginOptions.id]: asFunction(
|
||||
(cradle) => new klass(cradle, pluginOptions.options ?? {}),
|
||||
{
|
||||
lifetime: klass.LIFE_TIME || Lifetime.SINGLETON,
|
||||
}
|
||||
),
|
||||
})
|
||||
|
||||
container.registerAdd(
|
||||
AuthIdentifiersRegistrationName,
|
||||
asValue(pluginOptions.id)
|
||||
)
|
||||
}
|
||||
|
||||
export default async ({
|
||||
@@ -32,21 +33,13 @@ export default async ({
|
||||
| ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions
|
||||
) & { providers: ModuleProvider[] }
|
||||
>): Promise<void> => {
|
||||
// TODO: Temporary settings used by the starter, remove once the auth module is updated
|
||||
const isLegacyOptions =
|
||||
options?.providers?.length && !!(options?.providers[0] as any)?.name
|
||||
|
||||
// Note: For now we want to inject some providers out of the box
|
||||
const providerConfig = [
|
||||
{
|
||||
resolve: EmailPassProvider,
|
||||
options: {
|
||||
config: {
|
||||
emailpass: {},
|
||||
},
|
||||
},
|
||||
id: "emailpass",
|
||||
},
|
||||
...(isLegacyOptions ? [] : options?.providers ?? []),
|
||||
...(options?.providers ?? []),
|
||||
]
|
||||
|
||||
await moduleProviderLoader({
|
||||
|
||||
Reference in New Issue
Block a user