Skip to content

Commit

Permalink
fix(notifications): jwt middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
manuandru committed May 23, 2024
1 parent f5d734d commit dc498f8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions notifications-service/src/main/typescript/commons/utils/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare global {
P = unknown,
ResBody = any,
ReqBody = any,
ReqQuery = qs.ParsedQs,
ReqQuery = qs.ParsedQs
> {
user: UserJWTInfo;
}
Expand All @@ -48,12 +48,12 @@ const REFRESH_TOKEN_SECRET =
*/
export const generateAccessToken = (
user: UserInfo,
expiresIn: string = "1d",
expiresIn: string = "1d"
) => {
return jwt.sign(
{ username: user.username, email: user.email } as UserJWTInfo,
ACCESS_TOKEN_SECRET,
{ expiresIn: expiresIn },
{ expiresIn: expiresIn }
);
};

Expand All @@ -65,12 +65,12 @@ export const generateAccessToken = (
*/
export const generateRefreshToken = (
user: UserInfo,
expiresIn: string = "1w",
expiresIn: string = "1w"
) => {
return jwt.sign(
{ username: user.username, email: user.email } as UserJWTInfo,
REFRESH_TOKEN_SECRET,
{ expiresIn: expiresIn },
{ expiresIn: expiresIn }
);
};

Expand Down Expand Up @@ -120,7 +120,7 @@ export const verifyRefreshToken = (token: string) => {
export const JWTAuthenticationMiddleware = (
req: Request,
res: Response,
next: NextFunction,
next: NextFunction
): void => {
const accessToken = req.headers.authorization?.split(" ")[1];
if (!accessToken) {
Expand Down Expand Up @@ -149,7 +149,7 @@ export const JWTAuthenticationMiddleware = (
export const JWTRefreshTokenMiddleware = (
req: Request,
res: Response,
next: NextFunction,
next: NextFunction
): void => {
const accessToken = req.cookies.jwt;
if (!accessToken) {
Expand Down

0 comments on commit dc498f8

Please sign in to comment.