Skip to content

Fix Authentication and Admin Login Issues#8

Open
virtuehearts wants to merge 1 commit intomainfrom
fix-auth-and-admin-login-17369478161150935137
Open

Fix Authentication and Admin Login Issues#8
virtuehearts wants to merge 1 commit intomainfrom
fix-auth-and-admin-login-17369478161150935137

Conversation

@virtuehearts
Copy link
Copy Markdown
Owner

This change addresses the issues with admin login and Google OAuth configuration.

Key improvements:

  1. Email Case-Insensitivity: All email-based authentication and registration now normalize emails to lowercase. This prevents login failures due to case mismatches.
  2. Robust Admin Login: The admin can now reliably log in using the credentials specified in the environment variables. If the admin user doesn't exist in the database, it is automatically created on the first successful login.
  3. Graceful Google OAuth: The Google sign-in button is now only displayed if the Google Client ID and Secret are provided. This prevents the "localhost" redirect error and other OAuth failures when the provider is not configured.
  4. Environment Flexibility: Removed the hardcoded NEXTAUTH_URL="http://localhost:3000" from the initialization script, which was causing incorrect redirects in production/non-local environments. NextAuth will now correctly infer the URL from request headers or rely on environment overrides.
  5. Improved Initialization: The scripts/init.js now includes placeholders for Google credentials, making it easier for users to know what needs to be configured.

Verified with Playwright and tested against the local SQLite database.


PR created automatically by Jules for task 17369478161150935137 started by @virtuehearts

… login

- Normalize email addresses to lowercase across registration, login, and Google OAuth to ensure case-insensitive access.
- Update `lib/auth.ts` with a fallback mechanism allowing admin login via environment variables even if the user record doesn't exist yet.
- Make `GoogleProvider` conditional based on the presence of client ID and secret, preventing OAuth errors when unconfigured.
- Update the login page to dynamically render the Google sign-in button only when configured.
- Remove hardcoded `NEXTAUTH_URL` default in `scripts/init.js` to allow auto-detection in non-local environments.
- Add Google credential placeholders to `scripts/init.js` for better discoverability.

Co-authored-by: virtuehearts <17357584+virtuehearts@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant