generated from nhcarrigan/template
feat: bunch of work done here, got comments and edit and delete
This commit is contained in:
@@ -11,6 +11,18 @@ declare module "fastify" {
|
||||
}
|
||||
}
|
||||
|
||||
declare module "@fastify/jwt" {
|
||||
interface FastifyJWT {
|
||||
user: {
|
||||
id: string;
|
||||
username: string;
|
||||
email?: string;
|
||||
avatar?: string;
|
||||
isAdmin: boolean;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const authPlugin: FastifyPluginAsync = async (app) => {
|
||||
// Register JWT plugin
|
||||
app.register(fastifyJwt, {
|
||||
@@ -19,6 +31,14 @@ const authPlugin: FastifyPluginAsync = async (app) => {
|
||||
cookieName: "auth-token",
|
||||
signed: false,
|
||||
},
|
||||
formatUser: (payload: { sub: string; email?: string; username: string; isAdmin: boolean }) => {
|
||||
return {
|
||||
id: payload.sub,
|
||||
email: payload.email,
|
||||
username: payload.username,
|
||||
isAdmin: payload.isAdmin,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// Register cookie plugin
|
||||
|
||||
Reference in New Issue
Block a user