Skip to content

added complete authentication layer with registration, login and pers…#9

Merged
ranuru merged 1 commit into
developmentfrom
feature/auth
May 8, 2026
Merged

added complete authentication layer with registration, login and pers…#9
ranuru merged 1 commit into
developmentfrom
feature/auth

Conversation

@ranuru

@ranuru ranuru commented May 8, 2026

Copy link
Copy Markdown
Owner

…istence of users across sessions

This pull request introduces user authentication to the frontend, implements login and registration pages, and updates the backend and development environment to use PostgreSQL instead of H2. It also refactors navigation and page layouts to support authenticated user flows and improves security by hiding password hashes in API responses.

Frontend: User Authentication and Navigation

  • Implements a full authentication flow:
    • Adds AuthContext for managing user state and authentication logic, including login, registration, and logout methods (frontend/src/context/AuthContext.jsx).
    • Adds LoginPage and RegisterPage components for user sign-in and registration (frontend/src/pages/LoginPage.jsx, frontend/src/pages/RegisterPage.jsx) [1] [2].
    • Updates App.jsx to provide authentication context, protect challenge routes, and add routes for login/register (frontend/src/App.jsx).
    • Refactors API requests to use dynamic credentials from local storage instead of hardcoded values (frontend/src/api/axios.js).
  • Adds a NavBar component that displays user info and logout, and integrates it into all main pages (frontend/src/components/NavBar.jsx, frontend/src/pages/ChallengeListPage.jsx, frontend/src/pages/ChallengePage.jsx, frontend/src/pages/AboutPage.jsx) [1] [2] [3] [4].

Backend and Environment: PostgreSQL Migration

  • Switches backend database from H2 to PostgreSQL:
    • Updates Spring Boot datasource configuration to use PostgreSQL and environment variables (src/main/resources/application.properties).
    • Adds a PostgreSQL service to docker-compose.yml with persistent storage, health checks, and connects the backend to it [1] [2].
    • Keeps H2 for tests only (src/test/resources/application.properties).
  • Updates VSCode settings for automatic Java build configuration (.vscode/settings.json).

Security Improvements

  • Ensures password hashes are write-only and never exposed in API responses by using @JsonProperty(access = WRITE_ONLY) in the AppUser entity (src/main/java/no/hvl/schemalab/model/AppUser.java).

These changes collectively enable secure user authentication, improve developer experience, and prepare the app for production use with a real database.

@ranuru ranuru self-assigned this May 8, 2026
@ranuru ranuru linked an issue May 8, 2026 that may be closed by this pull request
@ranuru ranuru merged commit 10a41d6 into development May 8, 2026
2 checks passed
@ranuru ranuru deleted the feature/auth branch May 8, 2026 10:16
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.

feature/auth

1 participant