@main12/auth-login 0.1.7 → 0.1.8

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.
@@ -4,9 +4,13 @@ import { pluginConfig } from '../../config.js';
4
4
  import LoginPageTailwind from './LoginPageTailwind.js';
5
5
  import LoginPageHero from './LoginPageHero.js';
6
6
  export default function LoginPage(props) {
7
- return pluginConfig.style === 'hero-ui' ? /*#__PURE__*/ _jsx(LoginPageHero, {
7
+ const resolved = {
8
+ showGoogleOAuth: pluginConfig.googleOAuthEnabled,
8
9
  ...props
10
+ };
11
+ return pluginConfig.style === 'hero-ui' ? /*#__PURE__*/ _jsx(LoginPageHero, {
12
+ ...resolved
9
13
  }) : /*#__PURE__*/ _jsx(LoginPageTailwind, {
10
- ...props
14
+ ...resolved
11
15
  });
12
16
  }
@@ -4,9 +4,13 @@ import { pluginConfig } from '../../config.js';
4
4
  import SignupPageTailwind from './SignupPageTailwind.js';
5
5
  import SignupPageHero from './SignupPageHero.js';
6
6
  export default function SignupPage(props) {
7
- return pluginConfig.style === 'hero-ui' ? /*#__PURE__*/ _jsx(SignupPageHero, {
7
+ const resolved = {
8
+ showGoogleOAuth: pluginConfig.googleOAuthEnabled,
8
9
  ...props
10
+ };
11
+ return pluginConfig.style === 'hero-ui' ? /*#__PURE__*/ _jsx(SignupPageHero, {
12
+ ...resolved
9
13
  }) : /*#__PURE__*/ _jsx(SignupPageTailwind, {
10
- ...props
14
+ ...resolved
11
15
  });
12
16
  }
package/dist/config.d.ts CHANGED
@@ -6,4 +6,5 @@ export type AuthStyle = 'tailwind' | 'hero-ui';
6
6
  export declare const pluginConfig: {
7
7
  style: AuthStyle;
8
8
  logoUrl?: string;
9
+ googleOAuthEnabled: boolean;
9
10
  };
package/dist/config.js CHANGED
@@ -2,5 +2,6 @@
2
2
  * Shared plugin configuration — set by the plugin factory at init time,
3
3
  * read by all client components at render time.
4
4
  */ export const pluginConfig = {
5
- style: 'tailwind'
5
+ style: 'tailwind',
6
+ googleOAuthEnabled: true
6
7
  };
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export interface AuthLoginPluginOptions {
7
7
  domain?: string;
8
8
  style?: AuthStyle;
9
9
  logo?: string;
10
- /** Enable Google OAuth — reads GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET from env */
10
+ /** Enable Google OAuth. Default: auto-detects GOOGLE_CLIENT_ID env var. Set false to force-disable. */
11
11
  googleOAuth?: boolean;
12
12
  }
13
13
  export declare const authLoginPlugin: (options?: AuthLoginPluginOptions) => (config: Config) => Config;
package/dist/index.js CHANGED
@@ -3,16 +3,23 @@ import { googleOAuthEndpoints } from './endpoints/googleOAuth.js';
3
3
  import { pluginConfig } from './config.js';
4
4
  export const authLoginPlugin = (options = {})=>(config)=>{
5
5
  if (options.enabled === false) return config;
6
- // Set global style config — all page components read this at render time
6
+ // Set global config — all components read this at render time
7
7
  pluginConfig.style = options.style || 'tailwind';
8
8
  pluginConfig.logoUrl = options.logo;
9
+ // Google OAuth: auto-detect from env vars
10
+ if (options.googleOAuth === false) {
11
+ pluginConfig.googleOAuthEnabled = false;
12
+ } else {
13
+ const hasGoogleCreds = !!(process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET);
14
+ pluginConfig.googleOAuthEnabled = options.googleOAuth === true || hasGoogleCreds;
15
+ }
9
16
  // Register auth API endpoints
10
17
  config.endpoints = [
11
18
  ...config.endpoints || [],
12
19
  ...authEndpoints
13
20
  ];
14
- // Register Google OAuth endpoints if enabled
15
- if (options.googleOAuth !== false) {
21
+ // Register Google OAuth endpoints only if enabled
22
+ if (pluginConfig.googleOAuthEnabled) {
16
23
  config.endpoints = [
17
24
  ...config.endpoints,
18
25
  ...googleOAuthEndpoints
@@ -22,7 +29,7 @@ export const authLoginPlugin = (options = {})=>(config)=>{
22
29
  const incomingOnInit = config.onInit;
23
30
  config.onInit = async (payload)=>{
24
31
  if (incomingOnInit) await incomingOnInit(payload);
25
- payload.logger.info(`[auth-login] Initialized (style: ${pluginConfig.style}) for ${options.projectName || 'project'}`);
32
+ payload.logger.info(`[auth-login] Initialized (style: ${pluginConfig.style}, googleOAuth: ${pluginConfig.googleOAuthEnabled}) for ${options.projectName || 'project'}`);
26
33
  };
27
34
  return config;
28
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@main12/auth-login",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Reusable Payload CMS auth plugin — login, signup, OTP, forgot password, branded emails, Powered by Main12",
5
5
  "license": "MIT",
6
6
  "type": "module",