Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: JWT Backend Storage, JWT Bugs #136

Merged
merged 19 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"endOfLine": "lf"
}
16 changes: 8 additions & 8 deletions backend/api-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM nginx

WORKDIR /app

COPY nginx.conf .

CMD ["nginx", "-c", "/app/nginx.conf", "-g", "daemon off;"]

FROM nginx
WORKDIR /app
COPY nginx.conf .
CMD ["nginx", "-c", "/app/nginx.conf", "-g", "daemon off;"]
30 changes: 15 additions & 15 deletions backend/collaboration-service/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM node:18

WORKDIR /usr/src/app

RUN npm install -g nodemon
RUN npm install -g ts-node

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8082

FROM node:18
WORKDIR /usr/src/app
RUN npm install -g nodemon
RUN npm install -g ts-node
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8082
CMD ["ts-node", "./app.ts"]
2 changes: 1 addition & 1 deletion backend/collaboration-service/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const SOCKET_IO_PORT =
(process.env.SOCKET_IO_PORT as string) || (process.env.PORT as string);

const setupWSConnection = require("y-websocket/bin/utils").setupWSConnection;

const mongoose = require("mongoose");
mongoose.connect(process.env.MONGODB_URL, {
useNewUrlParser: true,
Expand Down
32 changes: 16 additions & 16 deletions backend/matching-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM node:18

RUN npm install -g nodemon

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install --frozen-lockfile

COPY . .

EXPOSE 9000

CMD ["npm", "start"]

FROM node:18
RUN npm install -g nodemon
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install --frozen-lockfile
COPY . .
EXPOSE 9000
CMD ["npm", "start"]
19 changes: 11 additions & 8 deletions backend/question-service/src/middleware/authMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { Request, Response, NextFunction } from "express";
import { authenticateAccessToken } from "../utils/jwt";

interface User {
export interface User {
id: number;
password: string;
username: string;
email: string;
role: string;
languages: string[];
languages: { id: number; language: string }[];
githubId?: number;
}

interface JwtPayload {
user: User;
export interface UserWithoutPassword {
id: number;
role: string;
}

export interface JwtPayload {
user: UserWithoutPassword;
exp: number;
iat: number;
}
Expand All @@ -21,10 +28,6 @@ export async function verifyAccessToken(
res: Response,
next: NextFunction,
) {
if (req.cookies["serverToken"] == process.env.SERVER_SECRET) {
next();
return;
}
juslam19 marked this conversation as resolved.
Show resolved Hide resolved
const accessToken = req.cookies["accessToken"]; // If JWT token is stored in a cookie

if (!accessToken) {
Expand Down
Loading