mirror of
https://github.com/bubblecup-12/VogelSocialMedia.git
synced 2025-07-09 12:08:47 +00:00
add refresh token endpoints
This commit is contained in:
parent
9be66a0a2f
commit
a9bda19891
8 changed files with 235 additions and 35 deletions
|
@ -2,20 +2,14 @@ import express, { NextFunction, Request, Response } from "express";
|
|||
import jwt, { TokenExpiredError } from "jsonwebtoken";
|
||||
import dotenv from "dotenv";
|
||||
import { StatusCodes } from "http-status-codes";
|
||||
import { JwtPayload } from "../types/tokens";
|
||||
dotenv.config();
|
||||
|
||||
// Import the JWT secret from environment variables
|
||||
const JWT_SECRET: string = process.env.TOKEN_SECRET!;
|
||||
if (!JWT_SECRET) console.error("No JWT secret provided");
|
||||
|
||||
// Define the structure of the JWT payload
|
||||
interface JwtPayload {
|
||||
id: string;
|
||||
username: string;
|
||||
role: string;
|
||||
iat: number;
|
||||
exp: number;
|
||||
}
|
||||
|
||||
|
||||
// Extend the Express Request interface to include the user property
|
||||
declare global {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue