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

dummy #298

Closed
wants to merge 7 commits into from
Closed

dummy #298

Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
10 changes: 5 additions & 5 deletions backend/middlewares/auth-middleware.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { JWT_SECRET } from '../config/utils.js';
import { ApiError } from '../utils/api-error.js'
import { ApiError } from '../utils/api-error.js';
import { HTTP_STATUS, RESPONSE_MESSAGES } from '../utils/constants.js';
import jwt from 'jsonwebtoken';

export const authMiddleware = async (req, res, next) => {
const token = req.cookies?.access_token
const token = req.cookies?.access_token;
if (!token) {
return next(new ApiError(HTTP_STATUS.BAD_REQUEST, RESPONSE_MESSAGES.USERS.RE_LOGIN))
return next(new ApiError(HTTP_STATUS.BAD_REQUEST, RESPONSE_MESSAGES.USERS.RE_LOGIN));
}

if (token) {
await jwt.verify(token, JWT_SECRET, (error, payload) => {
if (error) {
return new ApiError(HTTP_STATUS.FORBIDDEN, RESPONSE_MESSAGES.USERS.INVALID_TOKEN)
return new ApiError(HTTP_STATUS.FORBIDDEN, RESPONSE_MESSAGES.USERS.INVALID_TOKEN);
}
req.user = payload;
next();
Expand All @@ -23,7 +23,7 @@ export const authMiddleware = async (req, res, next) => {
export const isAdminMiddleware = async (req, res, next) => {
const role = req.user.role;
if (role !== 'ADMIN') {
return new ApiError(HTTP_STATUS.UNAUTHORIZED, RESPONSE_MESSAGES.USERS.UNAUTHORIZED_USER)
return new ApiError(HTTP_STATUS.UNAUTHORIZED, RESPONSE_MESSAGES.USERS.UNAUTHORIZED_USER);
}
next();
};
1 change: 1 addition & 0 deletions frontend/src/components/post-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { TestProps } from '@/types/test-props';

export default function PostCard({ post, testId = 'postcard' }: { post: Post } & TestProps) {
const navigate = useNavigate();
console.log('This is for the testing purpose');
const slug = createSlug(post.title);
return (
<div
Expand Down
Loading