fix: switch to express-ejs-layouts, pass title from controller
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -30,6 +30,7 @@
|
|||||||
"class-validator": "^0.14.1",
|
"class-validator": "^0.14.1",
|
||||||
"cookie-parser": "^1.4.7",
|
"cookie-parser": "^1.4.7",
|
||||||
"ejs": "^6.0.1",
|
"ejs": "^6.0.1",
|
||||||
|
"express-ejs-layouts": "^2.5.1",
|
||||||
"helmet": "^8.0.0",
|
"helmet": "^8.0.0",
|
||||||
"ioredis": "^5.5.0",
|
"ioredis": "^5.5.0",
|
||||||
"nestjs-pino": "^4.1.0",
|
"nestjs-pino": "^4.1.0",
|
||||||
@@ -6472,6 +6473,11 @@
|
|||||||
"url": "https://opencollective.com/express"
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/express-ejs-layouts": {
|
||||||
|
"version": "2.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/express-ejs-layouts/-/express-ejs-layouts-2.5.1.tgz",
|
||||||
|
"integrity": "sha512-IXROv9n3xKga7FowT06n1Qn927JR8ZWDn5Dc9CJQoiiaaDqbhW5PDmWShzbpAa2wjWT1vJqaIM1S6vJwwX11gA=="
|
||||||
|
},
|
||||||
"node_modules/express/node_modules/cookie-signature": {
|
"node_modules/express/node_modules/cookie-signature": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"class-validator": "^0.14.1",
|
"class-validator": "^0.14.1",
|
||||||
"cookie-parser": "^1.4.7",
|
"cookie-parser": "^1.4.7",
|
||||||
"ejs": "^6.0.1",
|
"ejs": "^6.0.1",
|
||||||
|
"express-ejs-layouts": "^2.5.1",
|
||||||
"helmet": "^8.0.0",
|
"helmet": "^8.0.0",
|
||||||
"ioredis": "^5.5.0",
|
"ioredis": "^5.5.0",
|
||||||
"nestjs-pino": "^4.1.0",
|
"nestjs-pino": "^4.1.0",
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Logger } from 'nestjs-pino';
|
|||||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||||
import * as helmet from 'helmet';
|
import * as helmet from 'helmet';
|
||||||
import cookieParser from 'cookie-parser';
|
import cookieParser from 'cookie-parser';
|
||||||
|
import expressLayouts from 'express-ejs-layouts';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
import { existsSync } from 'node:fs';
|
import { existsSync } from 'node:fs';
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
@@ -41,6 +42,8 @@ async function bootstrap(): Promise<void> {
|
|||||||
if (existsSync(viewsPath)) {
|
if (existsSync(viewsPath)) {
|
||||||
app.setBaseViewsDir(viewsPath);
|
app.setBaseViewsDir(viewsPath);
|
||||||
app.setViewEngine('ejs');
|
app.setViewEngine('ejs');
|
||||||
|
app.use(expressLayouts);
|
||||||
|
app.set('layout', 'layouts/main');
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicPath = join(process.cwd(), 'public');
|
const publicPath = join(process.cwd(), 'public');
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ export class WebController {
|
|||||||
@Get('login')
|
@Get('login')
|
||||||
@Render('auth/login')
|
@Render('auth/login')
|
||||||
loginPage() {
|
loginPage() {
|
||||||
return {};
|
return { title: 'Login' };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Public()
|
@Public()
|
||||||
@Get('register')
|
@Get('register')
|
||||||
@Render('auth/register')
|
@Render('auth/register')
|
||||||
registerPage() {
|
registerPage() {
|
||||||
return {};
|
return { title: 'Register' };
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AuthGuard('jwt'))
|
@UseGuards(AuthGuard('jwt'))
|
||||||
@@ -51,7 +51,7 @@ export class WebController {
|
|||||||
createdAt: true,
|
createdAt: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return { user: profile };
|
return { title: 'Profile', user: profile };
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AuthGuard('jwt'), RolesGuard)
|
@UseGuards(AuthGuard('jwt'), RolesGuard)
|
||||||
@@ -79,6 +79,7 @@ export class WebController {
|
|||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
title: 'Admin',
|
||||||
user: { email: jwtUser.email, role: jwtUser.role },
|
user: { email: jwtUser.email, role: jwtUser.role },
|
||||||
users,
|
users,
|
||||||
stats: { users: totalUsers, clients, activeSessions },
|
stats: { users: totalUsers, clients, activeSessions },
|
||||||
@@ -110,6 +111,7 @@ export class WebController {
|
|||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
title: 'Admin',
|
||||||
user: { email: jwtUser.email, role: jwtUser.role },
|
user: { email: jwtUser.email, role: jwtUser.role },
|
||||||
users,
|
users,
|
||||||
stats: { users: totalUsers, clients, activeSessions },
|
stats: { users: totalUsers, clients, activeSessions },
|
||||||
@@ -133,6 +135,7 @@ export class WebController {
|
|||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
title: 'Admin - OAuth Clients',
|
||||||
user: { email: jwtUser.email, role: jwtUser.role },
|
user: { email: jwtUser.email, role: jwtUser.role },
|
||||||
clients,
|
clients,
|
||||||
stats: { users: totalUsers, clients: totalClients, activeSessions },
|
stats: { users: totalUsers, clients: totalClients, activeSessions },
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
<% title = 'Admin - OAuth Clients'; %>
|
|
||||||
<% include ../layouts/main.ejs %>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<ul class="nav nav-tabs mb-3">
|
<ul class="nav nav-tabs mb-3">
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
<% title = 'Admin'; %>
|
|
||||||
<% include ../layouts/main.ejs %>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="row mb-4">
|
<div class="row mb-4">
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
<% title = 'Login'; %>
|
|
||||||
<% include ../layouts/main.ejs %>
|
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<div class="card shadow">
|
<div class="card shadow">
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
<% title = 'Register'; %>
|
|
||||||
<% include ../layouts/main.ejs %>
|
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<div class="card shadow">
|
<div class="card shadow">
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
<% title = 'Profile'; %>
|
|
||||||
<% include ../layouts/main.ejs %>
|
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="card shadow">
|
<div class="card shadow">
|
||||||
|
|||||||
Reference in New Issue
Block a user