Skip to content

Conversation

@Devasy
Copy link
Owner

@Devasy Devasy commented Jun 22, 2025

Email/Password Authentication Implementation

🎯 Overview

This PR implements a complete email/password authentication system for the Splitwiser app, removing Firebase/Google authentication dependencies to focus on core functionality.

✨ Features Implemented

Authentication System

  • Email/Password Signup - Users can create accounts with email, password, and name
  • Email/Password Login - Secure login with proper error handling
  • Token Management - JWT access tokens and refresh tokens with secure storage
  • Auto Token Refresh - Automatic token refresh on 401 responses
  • Session Persistence - Authentication state persists across app restarts

Frontend (React Native/Expo)

  • AuthContext - Comprehensive authentication context with proper state management
  • LoginScreen - Clean, modern UI for login/signup with form validation
  • Form Validation - Email format validation and required field checks
  • Error Handling - Proper error messages from backend API
  • Loading States - Visual feedback during authentication requests
  • Secure Storage - Refresh tokens stored securely using expo-secure-store

Code Quality

  • TypeScript - Full type safety for authentication flow
  • Clean Architecture - Separation of concerns between UI and business logic
  • Error Boundaries - Proper error handling throughout the auth flow
  • Axios Interceptors - Automatic token attachment and refresh handling

🗑️ Removed Dependencies

  • ❌ Firebase SDK (firebase)
  • ❌ Google Auth (expo-auth-session)
  • ❌ Firebase config files
  • ❌ Google sign-in UI components
  • ❌ Debug console statements

🔧 Technical Details

API Integration

  • Uses production backend: https://splitwiser-production.up.railway.app
  • Endpoints: /auth/login/email, /auth/signup/email, /auth/refresh
  • Proper HTTP status code handling and error message extraction

Security Features

  • Secure token storage using Expo SecureStore
  • Automatic token refresh on expiration
  • Proper logout with token cleanup
  • Request/response interceptors for seamless auth flow

UI/UX Improvements

  • Modern, clean login/signup interface
  • Green theme consistent with app branding
  • Responsive design with keyboard handling
  • Clear error messages and loading indicators

🧪 Testing

  • ✅ Signup flow tested and working
  • ✅ Login flow tested and working
  • ✅ Error handling verified with invalid credentials
  • ✅ Token persistence tested across app restarts
  • ✅ Form validation working correctly

📝 Future Work

Created issue #8 for Google/Firebase authentication implementation as an enhancement feature.

🔗 Related Issues

  • Resolves authentication setup requirements
  • Addresses clean UI implementation
  • Sets foundation for future Google auth integration

Ready for Review
All authentication flows are working correctly with the backend API.

Devasy and others added 4 commits June 22, 2025 00:34
- Changed project name in package.json to "splitwiser" and updated main entry point.
- Updated dependencies to newer versions for better performance and security.
- Added HomeScreen component for user profile display and logout functionality.
- Created LoginScreen component for user authentication with email/password and Google sign-in options.
- Modified tsconfig.json for improved TypeScript support and configuration.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 22, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Devasy Devasy merged commit 1e56137 into feature/auth-service-workflow Jun 22, 2025
3 checks passed
@codecov
Copy link

codecov bot commented Jun 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.67%. Comparing base (a0e221a) to head (d6c5489).
Report is 1 commits behind head on feature/auth-service-workflow.

Additional details and impacted files
@@                      Coverage Diff                       @@
##           feature/auth-service-workflow       #9   +/-   ##
==============================================================
  Coverage                          65.67%   65.67%           
==============================================================
  Files                                 12       12           
  Lines                                574      574           
==============================================================
  Hits                                 377      377           
  Misses                               197      197           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Devasy Devasy deleted the feat/new-expo-ui branch June 22, 2025 05:54
Devasy added a commit that referenced this pull request Jun 22, 2025
* feat: implement authentication module with JWT support and Firebase integration

* 📝 Add docstrings to `feature/auth-service-workflow`

Docstrings generation was requested by @Devasy23.

* #3 (comment)

The following files were modified:

* `backend/app/auth/routes.py`
* `backend/app/auth/security.py`
* `backend/app/auth/service.py`
* `backend/app/database.py`
* `backend/app/dependencies.py`
* `backend/generate_secret.py`
* `backend/main.py`

* feat: add Procfile and runtime.txt, configure CORS settings, and improve AuthService docstring

* feat: add deployment configurations for Railway, including Dockerfile, .dockerignore, and environment setup

* feat: remove Dockerfile and Procfile, update nixpacks.toml and railway.toml for backend directory structure, and add requirements.txt

* fix: update pip installation command for consistency and add nixpacks configuration to disable venv creation

* fix: update nixpacks and railway configurations to simplify installation and execution commands

* feat: enhance Firebase authentication setup with environment variable support and improve CORS configuration for production

* feat: enhance CORS middleware with detailed OPTIONS handler and debugging support

* feat: add debugging section for CORS issues and update allowed_origins for production

* feat(auth): login and signup screen with integrated backend

Co-authored-by: Devasy Patel <[email protected]>

* feat(google-signin): add google sign in UI component

* feat: Add authentication tests for email signup and login

This commit introduces a test suite for the email-based authentication
endpoints (`/auth/signup/email` and `/auth/login/email`).

Key changes include:

1.  **Test Implementation (`backend/tests/auth/test_auth_routes.py`):**
    *   Comprehensive tests covering successful registration and login.
    *   Tests for error scenarios: existing email, incorrect password,
        non-existent user.
    *   Parameterized tests for invalid input validation (missing fields,
        short passwords, invalid email formats) returning 422 errors.

2.  **Mocking (`backend/tests/conftest.py`):**
    *   MongoDB Mocking: Implemented an auto-use pytest fixture (`mock_db`)
        using `mongomock-motor` to simulate MongoDB interactions. This
        fixture patches `app.auth.service.get_database` to ensure
        `AuthService` uses the mock database during tests.
    *   Firebase Mocking: Added a session-scoped fixture (`mock_firebase_admin`)
        to mock `firebase_admin.initialize_app`, `credentials.Certificate`,
        and `auth`. This prevents actual Firebase SDK initialization, which
        is not needed for these tests and might fail in CI environments.

3.  **Test Configuration (`backend/pytest.ini`):**
    *   Created `pytest.ini` to define test-specific environment
        variables (e.g., `SECRET_KEY`, `TESTING=True`).
    *   Configured `asyncio_mode` and test discovery patterns.

4.  **Dependencies (`backend/requirements.txt`):**
    *   Added `pytest`, `pytest-asyncio`, `httpx`, `mongomock-motor`,
        and `pytest-env` to support the testing framework and environment
        configuration.

All 13 tests for the authentication routes are passing. The test setup
ensures that tests are isolated and do not depend on external services
like a live MongoDB instance or Firebase.

* feat: Add GitHub Actions workflow to run backend tests

* fix(tests): update test command to run specific auth test file

* fix(tests): update test command to run all backend tests

* fix: remove duplicate entry for .vscode in .gitignore

* fix: update Python setup action to version 5 in GitHub Actions workflow

* Integrate Codecov for test coverage reporting

This commit introduces Codecov integration into the GitHub Actions workflow.

Key changes:
- Added `pytest-cov` to project dependencies.
- Modified the `run-tests.yml` workflow:
    - Adjusted `PYTHONPATH` for correct coverage path mapping.
    - Updated the `pytest` command to generate an XML coverage report (`coverage.xml`).
    - Added a new step to upload the `coverage.xml` report to Codecov using `codecov/codecov-action@v4`.

This will enable tracking of test coverage over time and provide insights into code quality via Codecov.

* feat: enhance CORS configuration with allow_all_origins option

* feat(auth): firebase google authentication code update

* Implement Email/Password Authentication with Clean UI (#9)

* feat: Update frontend package and add authentication screens

- Changed project name in package.json to "splitwiser" and updated main entry point.
- Updated dependencies to newer versions for better performance and security.
- Added HomeScreen component for user profile display and logout functionality.
- Created LoginScreen component for user authentication with email/password and Google sign-in options.
- Modified tsconfig.json for improved TypeScript support and configuration.

* feat: update app configuration and remove deprecated Google authentication code

* fix: updates the package.json

* feat(auth): enhance login/signup error handling and add basic form validation

* fix(auth): ensure user_id is converted to ObjectId in get_current_user and update access token creation

* refactor: enhance login/signup flow with password validation and confirmation to incorporate review chnages

* Revert "refactor: enhance login/signup flow with password validation and confirmation to incorporate review chnages"

This reverts commit 7883d98.

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Vraj Patel <[email protected]>
Co-authored-by: Devasy Patel <[email protected]>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: patel.devasy.23 <[email protected]>
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.

3 participants