payload-better-auth 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/payload/plugin.js +6 -10
- package/dist/payload/plugin.js.map +1 -1
- package/package.json +1 -1
package/dist/payload/plugin.js
CHANGED
|
@@ -34,21 +34,17 @@ export const betterAuthPayloadPlugin = (pluginOptions)=>(config)=>{
|
|
|
34
34
|
if (!config.admin.components) {
|
|
35
35
|
config.admin.components = {};
|
|
36
36
|
}
|
|
37
|
-
if (!config.admin.components.beforeLogin) {
|
|
38
|
-
config.admin.components.beforeLogin = [];
|
|
39
|
-
}
|
|
40
|
-
config.admin.components.beforeLogin.push({
|
|
41
|
-
path: `payload-better-auth/rsc#BetterAuthLoginServer`,
|
|
42
|
-
serverProps: {
|
|
43
|
-
authClientOptions
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
37
|
if (!config.admin.components.views) {
|
|
47
38
|
config.admin.components.views = {};
|
|
48
39
|
}
|
|
49
40
|
if (!config.admin.components.views.login) {
|
|
50
41
|
config.admin.components.views.login = {
|
|
51
|
-
Component:
|
|
42
|
+
Component: {
|
|
43
|
+
path: 'payload-better-auth/rsc#BetterAuthLoginServer',
|
|
44
|
+
serverProps: {
|
|
45
|
+
authClientOptions
|
|
46
|
+
}
|
|
47
|
+
},
|
|
52
48
|
exact: true,
|
|
53
49
|
path: '/auth'
|
|
54
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payload/plugin.ts"],"sourcesContent":["import type { Config } from 'payload'\nimport type { BetterAuthLoginServerProps } from 'src/components/BetterAuthLoginServer.js'\n\nimport { createUsersCollection } from '../collections/Users/index.js'\nimport { triggerFullReconcile } from '../utils/payload-reconcile.js'\n\nexport type BetterAuthPayloadPluginOptions = {\n betterAuthClientOptions: BetterAuthLoginServerProps['authClientOptions']\n disabled?: boolean\n reconcileToken?: string\n}\n\nexport const betterAuthPayloadPlugin =\n (pluginOptions: BetterAuthPayloadPluginOptions) =>\n (config: Config): Config => {\n const authClientOptions = pluginOptions.betterAuthClientOptions\n\n const Users = createUsersCollection({\n authClientOptions,\n })\n if (!config.collections) {\n config.collections = [Users]\n } else if (config.collections.find((col) => col.slug === 'users')) {\n throw new Error('Payload-better-auth plugin: Users collection already present')\n } else {\n config.collections.push(Users)\n }\n\n /**\n * If the plugin is disabled, we still want to keep added collections/fields so the database schema is consistent which is important for migrations.\n * If your plugin heavily modifies the database schema, you may want to remove this property.\n */\n if (pluginOptions.disabled) {\n return config\n }\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n if (!config.admin) {\n config.admin = {}\n }\n\n if (!config.admin.user) {\n config.admin.user = Users.slug\n } else if (config.admin.user !== Users.slug) {\n throw new Error(\n 'Payload-better-auth plugin: admin.user property already set with conflicting value.',\n )\n }\n\n if (!config.admin.components) {\n config.admin.components = {}\n }\n\n if (!config.admin.components.
|
|
1
|
+
{"version":3,"sources":["../../src/payload/plugin.ts"],"sourcesContent":["import type { Config } from 'payload'\nimport type { BetterAuthLoginServerProps } from 'src/components/BetterAuthLoginServer.js'\n\nimport { createUsersCollection } from '../collections/Users/index.js'\nimport { triggerFullReconcile } from '../utils/payload-reconcile.js'\n\nexport type BetterAuthPayloadPluginOptions = {\n betterAuthClientOptions: BetterAuthLoginServerProps['authClientOptions']\n disabled?: boolean\n reconcileToken?: string\n}\n\nexport const betterAuthPayloadPlugin =\n (pluginOptions: BetterAuthPayloadPluginOptions) =>\n (config: Config): Config => {\n const authClientOptions = pluginOptions.betterAuthClientOptions\n\n const Users = createUsersCollection({\n authClientOptions,\n })\n if (!config.collections) {\n config.collections = [Users]\n } else if (config.collections.find((col) => col.slug === 'users')) {\n throw new Error('Payload-better-auth plugin: Users collection already present')\n } else {\n config.collections.push(Users)\n }\n\n /**\n * If the plugin is disabled, we still want to keep added collections/fields so the database schema is consistent which is important for migrations.\n * If your plugin heavily modifies the database schema, you may want to remove this property.\n */\n if (pluginOptions.disabled) {\n return config\n }\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n if (!config.admin) {\n config.admin = {}\n }\n\n if (!config.admin.user) {\n config.admin.user = Users.slug\n } else if (config.admin.user !== Users.slug) {\n throw new Error(\n 'Payload-better-auth plugin: admin.user property already set with conflicting value.',\n )\n }\n\n if (!config.admin.components) {\n config.admin.components = {}\n }\n\n if (!config.admin.components.views) {\n config.admin.components.views = {}\n }\n\n if (!config.admin.components.views.login) {\n config.admin.components.views.login = {\n Component: {\n path: 'payload-better-auth/rsc#BetterAuthLoginServer',\n serverProps: { authClientOptions },\n },\n exact: true,\n path: '/auth',\n }\n } else {\n throw new Error(\n 'Payload-better-auth plugin: admin.components.views.login property in config already set.',\n )\n }\n\n if (!config.admin.components.views.verifyEmail) {\n config.admin.components.views.verifyEmail = {\n Component: 'payload-better-auth/client#VerifyEmailInfoViewClient', // RSC or 'use client' component\n exact: true,\n path: '/auth/verify-email',\n }\n } else {\n throw new Error(\n 'Payload-better-auth plugin: admin.components.views.verifyEmail property in config already set.',\n )\n }\n\n if (!config.admin.routes) {\n config.admin.routes = {}\n }\n\n if (!config.admin.routes.login) {\n config.admin.routes.login = '/auth'\n } else {\n throw new Error(\n 'Payload-better-auth plugin: admin.routes.login property in config already set.',\n )\n }\n\n const incomingOnInit = config.onInit\n\n config.onInit = async (payload) => {\n // Ensure we are executing any existing onInit functions before running our own.\n if (incomingOnInit) {\n await incomingOnInit(payload)\n }\n await triggerFullReconcile({\n additionalHeaders: pluginOptions.betterAuthClientOptions.fetchOptions?.headers,\n betterAuthUrl: pluginOptions.betterAuthClientOptions.baseURL,\n payload,\n reconcileToken: pluginOptions.reconcileToken,\n })\n }\n\n return config\n }\n"],"names":["createUsersCollection","triggerFullReconcile","betterAuthPayloadPlugin","pluginOptions","config","authClientOptions","betterAuthClientOptions","Users","collections","find","col","slug","Error","push","disabled","endpoints","admin","user","components","views","login","Component","path","serverProps","exact","verifyEmail","routes","incomingOnInit","onInit","payload","addition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