-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/auth' of https://github.com/noahk004/ui-compone…
…nt-manager into feature/auth
- Loading branch information
Showing
16 changed files
with
1,405 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- CreateTable | ||
CREATE TABLE "Messages" ( | ||
"id" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "Messages_pkey" PRIMARY KEY ("id") | ||
); |
18 changes: 18 additions & 0 deletions
18
apps/api/prisma/migrations/20241223230044_usertabletest/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the `Messages` table. If the table is not empty, all the data it contains will be lost. | ||
*/ | ||
-- DropTable | ||
DROP TABLE "Messages"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "Users" ( | ||
"id" TEXT NOT NULL, | ||
"username" TEXT NOT NULL, | ||
"password" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "Users_pkey" PRIMARY KEY ("id") | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Request, Response, NextFunction, RequestHandler } from 'express'; | ||
import jwt from 'jsonwebtoken'; | ||
|
||
interface AuthRequest extends Request { | ||
user?: { | ||
userId: string; | ||
username: string; | ||
}; | ||
} | ||
|
||
interface JwtPayload { | ||
userId: string; | ||
username: string; | ||
} | ||
|
||
export const authenticateToken: RequestHandler = (req: AuthRequest, res: Response, next: NextFunction) => { | ||
const token = req.cookies.token; | ||
|
||
if (!token) { | ||
return res.status(401).json({ error: 'Authentication required' }); | ||
} | ||
|
||
try { | ||
const user = jwt.verify(token, process.env.JWT_SECRET!) as JwtPayload; | ||
req.user = user; | ||
next(); | ||
} catch (error) { | ||
return res.status(403).json({ error: 'Invalid token' }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import type { NextConfig } from "next"; | ||
import MiniCssExtractPlugin from "mini-css-extract-plugin"; | ||
|
||
const nextConfig: NextConfig = { | ||
/* config options here */ | ||
webpack: (config) => { | ||
config.plugins.push(new MiniCssExtractPlugin()); | ||
return config; | ||
} | ||
}; | ||
|
||
export default nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.