fix: Improve settings persistence and auth handling
The changes address several issues related to data persistence and security within the Condopay application. **Settings Persistence:** - **Condo Creation:** Corrected the logic for creating new condos. The system now correctly handles passing an empty string for the `id` when creating a new condo, allowing the backend service to generate the ID, rather than attempting to create a new ID on the frontend. - **Family Quota Parsing:** Enhanced the parsing of `customMonthlyQuota` for families to safely handle empty or whitespace-only input, preventing potential errors during data submission. **Authentication and Authorization:** - **Admin Role Enforcement:** Ensured that the default admin user created during database initialization always has the 'admin' role, even if it was previously changed or created incorrectly. - **Token Verification Error Handling:** Modified the JWT token verification to return a `401 Unauthorized` status for all token-related errors (e.g., expired, invalid). This will prompt the frontend to log out the user more effectively. - **Admin Access Logging:** Added console warnings when non-admin users attempt to access admin-only routes, providing better visibility into potential access control issues. **Infrastructure:** - **Docker Cleanup:** Removed unused and outdated Dockerfiles and `.dockerignore` content, streamlining the build process and removing potential confusion. These improvements enhance the reliability of data management for condos and families, strengthen security by ensuring proper role enforcement and error handling, and clean up the development infrastructure.
This commit is contained in:
20
Dockerfile
20
Dockerfile
@@ -1,20 +0,0 @@
|
||||
# Stage 1: Build
|
||||
FROM node:20-alpine as build
|
||||
WORKDIR /app
|
||||
# Copia package.json
|
||||
COPY package*.json ./
|
||||
# Usa npm install invece di ci per evitare errori se manca package-lock.json
|
||||
RUN npm install
|
||||
# Copia tutto il resto
|
||||
COPY . .
|
||||
# Esegui la build (genera la cartella dist)
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Serve con Nginx
|
||||
FROM nginx:alpine
|
||||
# Copia la build di React nella cartella di Nginx
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
# Copia la configurazione custom di Nginx
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
Reference in New Issue
Block a user